Conan DING
Conan DING

Reputation: 21

How to get azure ad refresh token with react

I am doing a project with React, msal-react, and msal-browser.

I can get an access token with functions provided with msal-react library, but I cannot get the refresh token manually.

I can see from the network that a token request is performed when user is logged in by redirect, and obviously returned both token and refresh token. However, the refresh token is very well protected and cannot be found under cookie, session storage, or the instance.

Is it possible for the frontend to get refresh token of azure ad?

sorry, I cannot post my code due to security requirements

Upvotes: 2

Views: 8833

Answers (1)

Thomas Norling
Thomas Norling

Reputation: 484

Refresh tokens are intentionally not returned on the public API surface as MSAL will handle all required token refreshes under the hood when you call acquireTokenSilent. If the backend service needs its own access token it needs to use a server side library such as msal-node. We do not recommend or support obtaining tokens using the SPA library and passing them down to a backend as tokens should only be sent to the resource they are intended for.

Upvotes: 2

Related Questions