An API that connects multiple Microsoft services, enabling data access and automation across platforms
Hi Luke,
Thanks for reaching out. For Graph SDK related issues I would suggest posting the issue on the respective Graph SDK Github forum.
Thanks.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am using the msgraph-sdk-javascript and have implemented a custom getAccessToken handler. This handler checks whether the user's access token has expired, and if so, posts to the MSGraph /token endpoint to get a new access_token, refresh_token, and expires_in time.
In another function (doWork), I attempt to process a request to the graph api up to 3 times. If the request fails 3 times, I end the user's connection and log some information for debugging. However, if a user's access token is expired when doWork is called, there appears to be a chance that the response to the endpoint is a 401 InvalidAuthenticationToken which triggers doWork to be called again and loops until it fails with the same error 3 times.
What have I already investigated:
/token./token does not fail - I have it wrapped in a try/catch and never get in the catch block.getAccessToken) is being called via the sdk client whenever this error is thrown. doWork loop. Seeing as how this is an error that is inconsistent (it only appears for users sometimes), and I can tell my handlers are being called, what would be the next steps in how to resolve this issue? Is there anything else that could cause a 401 I should be looking at?
Possible related issue: https://learn.microsoft.com/en-us/answers/questions/1290165/401-invalidauthenticationtoken-access-token-has-ex
// error thrown in doWork() 3 times
{
statusCode: 401,
code: 'InvalidAuthenticationToken',
body: '{"code":"InvalidAuthenticationToken","message":"Access token has expired or is not yet valid"}'
}
An API that connects multiple Microsoft services, enabling data access and automation across platforms
Hi Luke,
Thanks for reaching out. For Graph SDK related issues I would suggest posting the issue on the respective Graph SDK Github forum.
Thanks.