admin管理员组

文章数量:1417070

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);

});

本文标签: MS Graph Subscriptions Webhooks to Node JS Google Cloud FunctionsStack Overflow