Best practices for using msal-node and microsoft graph APIs in a serverless environment?

Patrick Brown 1 Reputation point
2022-03-21T16:50:49.813+00:00

I am running a NextJS serverless application.

I am using msal-node to acquire a token, which is then passed to the microsoft graph client ( @microsoft/microsoft-graph-client ) like this tutorial here: https://learn.microsoft.com/en-us/graph/tutorials/node?tutorial-step=3

However in that example the local token cache is used to find the account and acquireTokenSilent is used which is supposed to transparently handle token refresh

In a serverless application where it may be restarted at any time, what is the correct way to store, retrieve, and pass tokens to the graph client?

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,649 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,569 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. 2022-03-24T05:54:04.64+00:00

    Hi @Patrick Brown , Thanks for reaching out you can use refresh token if your access tokens have expired.

    186324-image.png

    Please refer the this refresh-tokens

    Hope this helps.