Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does acquireTokenSilent needs to be called everytime I need a token?

So I'm creating an app that could sign in using a microsoft account, I've already set up my application in azure and the permissions. It's already working but upon switching routes and using acquireTokenSilent again I'm receiving this error. I'm using loginRedirect ,the registered RedirectURI on my app is the authentication only, or should I register all my possible routes in my azure application?

https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core/samples/react-sample-app

I followed this sample and added some routing capabilities using react-router-dom

I am expecting it to be ok since I've already logged in but I'm receiving this

"AADSTS50011: The reply url specified in the request does not match the reply urls configured for the application: '308cc3d1-3214-48ce-99b2-697fc9211852'."


1 Answers

The error indicates that your token request specifies a reply url that is different from the one you have registered in AAD for this application. They need to be exactly the same.

You call AcquireTokenSilent before every set of API calls to ensure you have a valid token for these calls. The AcquireTokenSilent will return the token it already has in cache if it is still valid or get a new one using refresh token or cookies in case implicit id_token. You can only make this call however if you are sure that you already have an access token or use has already been authenticated by a previous non-silent acquire token call.

like image 126
Marc Avatar answered Nov 05 '25 09:11

Marc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!