GraphError: Subscription validation request failed despite Accessible Endpoint hosted on Google Cloud
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- node.js, typescript
- Ambito
- api
Direzione di ricerca
Start by comparing the subscription request and validation response described in the issue with the SDK path shown in the stack trace, especially @microsoft/microsoft-graph-client/lib/src/GraphRequest.js and GraphErrorHandler.js. Determine whether the SDK request differs from Postman or whether the failure is returned by Microsoft Graph; done means a reproducible cause and a confirmed fix or actionable report.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
Prerequisites
- Can you reproduce the problem?
- Are you running the latest version?
- Are you reporting to the correct repository?
- Did you perform a cursory search?
For more information, see the CONTRIBUTING guide.
Description
I've been working on implementing Microsoft Graph webhook subscriptions in my application, and I've run into an issue with subscription validation. Whenever I attempt to validate the subscription, I've consistently receive the following error message:
GraphError: Subscription validation request timed out.
My subscription server is deployed and hosted on Google Cloud Function v2, allowing all unauthenticated invocations.
The following verification is performed using Microsoft's Postman Collection:
- Endpoint is accessible on the internet with unauthenticated invocation
- Endpoint is returning 200OK, text-plain, decoded validationToken as intended
- Endpoint able to reply within 10s timeframe consistently
However, when I actually attempt to create subscription request using MicrosoftGraph Javascript SDK, the validation request always faces timeout issue despite it being accessible via PostMan.
Code Snippet to Invoke Subscription Request
const requestBody: Subscription =
changeType: "updated",
resource: `/users/${folderId}/drive/root
expirationDateTime: new Date(now.setDate(now.getDate() + 28)).toISOString(),
notificationUrl: `${process.env.ONEDRIVE_URL}/folders/${folderId}?workspaceId=${workspaceId}`,
clientState: "somerandomtext";
}
await driveClient.api("/subscriptions").post(requestBody);
Console Errors:
GraphError: Subscription validation request timed out.
at new GraphError (/code/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphError.js:34:28)
at GraphErrorHandler.constructErrorFromResponse (/code/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphErrorHandler.js:63:22)
at Function.<anonymous> (/code/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphErrorHandler.js:91:48)
at step (/code/node_modules/tslib/tslib.js:195:27)
at Object.next (/code/node_modules/tslib/tslib.js:176:57)
at /code/node_modules/tslib/tslib.js:169:75
at new Promise (<anonymous>)
at Object.__awaiter (/code/node_modules/tslib/tslib.js:165:16)
at GraphErrorHandler.getError (/code/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphErrorHandler.js:87:24)
at GraphRequest.<anonymous> (/code/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphRequest.js:315:84) {
statusCode: 400,
code: 'InvalidRequest',
requestId: 'uuid,
date: 2023-09-30T21:36:48.000Z,
body: '{"code":"InvalidRequest","message":"Subscription validation request timed out.","innerError":{"date":"2023-10-01T05:36:48","request-id":"uuid,"client-request-id":"uuid}}',
headers: HeadersList {
cookies: null,
[Symbol(headers map)]: Map(10) {
'cache-control' => [Object],
'transfer-encoding' => [Object],
'content-type' => [Object],
'content-encoding' => [Object],
'vary' => [Object],
'strict-transport-security' => [Object],
'request-id' => [Object],
'client-request-id' => [Object],
'x-ms-ags-diagnostic' => [Object],
'date' => [Object]
},
[Symbol(headers map sorted)]: null
}
}
Code Snippet to Listen for Subscription Validation
import { FastifyPluginAsyncTypebox } from "@fastify/type-provider-typebox";
import { Type } from "@sinclair/typebox";
export const ParamsSchema = Type.Object({
fid: Type.String(),
});
export const QuerySchema = Type.Object({
workspaceId: Type.RegEx(/^[0-9a-z]{25}$/),
validationToken: Type.Optional(Type.String()),
});
const main: FastifyPluginAsyncTypebox = async (app, options): Promise<void> => {
/**
* Listens to changes to a folder
*/
app.post("/", { schema: { params: ParamsSchema, querystring: QuerySchema } }, async (req, rep) => {
app.log.info("Received webhook request");
// If there is a validationToken parameter
// in the query string, this is the endpoint validation
// request sent by Microsoft Graph. Return the token
// as plain text with a 200 response
// https://docs.microsoft.com/graph/webhooks#notification-endpoint-validation
// https://github.com/microsoftgraph/nodejs-webhooks-sample/blob/main/routes/listen.js#L13
if (req.query.validationToken) {
return req.query.validationToken;
}
// Other logic but is commented
return {};
});
}
Screenshots: [If applicable, add screenshots to help explain your problem]
Logs from Google Cloud Console
Usage Information
Request ID - Value of the requestId field if you are receiving a Graph API error response
SDK Version - 3.0.7
- Node (Check, if using Node version of SDK)
Node Version - v18.17.1
I'm unsure why the validation request fails in my application but works with Postman. Can anyone offer guidance on what could be causing this issue or suggest potential solutions?
- Lingua principale
- TypeScript
- Stelle
- 833
- Fork
- 240
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoftgraph/msgraph-sdk-javascript
-
status:waiting-for-triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
-
Is anyone here? Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
microsoftgraph/msgraph-sdk-javascript#2005 · 1 reazione ·
-
Is it really correct that the Javascript version of the graph SDK doesn't offer typed requests? Apertastatus:waiting-for-triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
-
status:waiting-for-triage type:bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
microsoftgraph/msgraph-sdk-javascript#1999 · 2 commenti · 1 reazione ·
-
status:waiting-for-triage type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Tutte le issue di microsoftgraph/msgraph-sdk-javascript
Issue simili
-
[Bug]: Discord Activity titles with emoji are rejected as over 80 characters when they are not Apertaclawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
supermomonga/zcode-acp#24 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
growthbook/growthbook#7100 ·
-
triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100