最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

MS Graph Subscriptions Webhooks to Node JS Google Cloud Functions - Stack Overflow

programmeradmin0浏览0评论

I am trying to connect MS Graph Subscriptions to a Google HTTP Cloud Function on Node.js. To establish the trust between the MS Graph subscription and the HTTP Cloud Function a token needs to be exchanged. The token is received by the HTTP function and returned back to MS Graph but a Valdidation Error occurs.

{
    "error": {
        "code": "ValidationError",
        "message": "d2e35dec-a4ba-9142-1129-139539c37a74",
        "innerError": {
            "date": "2025-02-02T17:07:07",
            "request-id": "a975ae23-b3ae-454f-892a-581465fe87ba",
            "client-request-id": "d2e35dec-a4ba-9142-1129-139539c37a74"
        }
    }
}

The response from the HTTP Cloud Function as per below.

functions.http('groupsHttp', (req, res) => {

    let validationToken = req.query.validationToken;
    let validationTokenArray = validationToken.split(' ');
    let finalToken = validationTokenArray.at(-1).toString();

    return res.setHeader('Content-Type', 'text/plain; charset=utf-8').status(200).send(finalToken);

});

According to Microsoft these requirements need to be in place. 1.An HTTP 200 Status Code must be returned 2.The Content-Type must be of ‘text/plain’ 3.Return a body containing the Validation Token that was provided by the initial Graph request 4.All this must be done within 10 seconds of the initial Graph request

Any hint or idea what is missing here?

Tried various options of returning the response correctly but it is declined by MS Graph every time even when message and client-id aka token are matching.

I am trying to connect MS Graph Subscriptions to a Google HTTP Cloud Function on Node.js. To establish the trust between the MS Graph subscription and the HTTP Cloud Function a token needs to be exchanged. The token is received by the HTTP function and returned back to MS Graph but a Valdidation Error occurs.

{
    "error": {
        "code": "ValidationError",
        "message": "d2e35dec-a4ba-9142-1129-139539c37a74",
        "innerError": {
            "date": "2025-02-02T17:07:07",
            "request-id": "a975ae23-b3ae-454f-892a-581465fe87ba",
            "client-request-id": "d2e35dec-a4ba-9142-1129-139539c37a74"
        }
    }
}

The response from the HTTP Cloud Function as per below.

functions.http('groupsHttp', (req, res) => {

    let validationToken = req.query.validationToken;
    let validationTokenArray = validationToken.split(' ');
    let finalToken = validationTokenArray.at(-1).toString();

    return res.setHeader('Content-Type', 'text/plain; charset=utf-8').status(200).send(finalToken);

});

According to Microsoft these requirements need to be in place. 1.An HTTP 200 Status Code must be returned 2.The Content-Type must be of ‘text/plain’ 3.Return a body containing the Validation Token that was provided by the initial Graph request 4.All this must be done within 10 seconds of the initial Graph request

Any hint or idea what is missing here?

Tried various options of returning the response correctly but it is declined by MS Graph every time even when message and client-id aka token are matching.

Share Improve this question asked Feb 2 at 20:40 Ben SchleefBen Schleef 1
Add a comment  | 

1 Answer 1

Reset to default 0

Got the issue. You need to return not only the token but the whole string in text/plain to make it work.

functions.http('groupsHttp', (req, res) => {

    let validationToken = req.query.validationToken;

    return res.set('Content-Type', 'text/plain; charset=utf-8').status(200).send(validationToken);

});
发布评论

评论列表(0)

  1. 暂无评论