简体   繁体   中英

How do I update my access token with a refresh token in msal?

I used B2C and MSAL to configure the SPA certification. Then, the backend API access token, refresh token, and ID token are obtained from B2C and stored in localstorage. However, after about an hour I noticed that the access token was disabled. At this time, I believe I can use a refresh token to update my access token. I am a beginner and would be grateful if you could give me a sample or something. Thank you in advance.

MSAL takes care of refresh token for you. What you should do is always ask a token from MSAL before using one. If it needs to refresh it using a refresh token, it will just do that behind the scenes.

You can see an example here: https://learn.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-acquire-token . There it shows a general pattern where you first try acquireTokenSilent, and if that fails, use a popup/redirect to get new tokens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM