Cannot validate access token, maybe because of the nonce
See original GitHub issueI’m submitting a…
- Documentation issue or request
Library version
latest
Issue
I do the requests to get an access token :
import * as Msal from 'msal';
const MSAL = new Msal.UserAgentApplication({
auth: {
clientId: ***,
authority: ***,
},
cache: {
cacheLocation: 'localStorage',
storeAuthStateInCookie: true
}
});
await MSAL.loginPopup({})
const tokenResponse = await MSAL.acquireTokenSilent({
scopes: ['user.read']
});
// Send to my server API => cannot validate the access token
I see that this issue exists on others libs https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/609
I have a nonce in my token when I decode it in https://jwt.io/
Two options :
- Getting an access token without a nonce (is there a way to do this ? I have been searching the doc for a while with no luck)
- Process the token to make the token valid.
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (1 by maintainers)
Top Results From Across the Web
Unable to successfully validate an access token from Microsoft ...
I am using the Microsoft Graph API along with Microsoft Authentication Library (MSAL) to acquire access tokens and I can ...
Read more >Azure AD and the Un-validatable Access Token - Punny Stuff
Your API won't be able to validate the access token, indeed, there's a couple of things wrong with it if you intend to...
Read more >Nonce (nonce) claim must be a string present in the ID token
As a result, I now get the error message Nonce (nonce) claim must be a string present in the ID token when calling...
Read more >Purpose of nonce validation in OpenID Connect implicit flow
If the nonce is not validated, an attacker could substitute a different access token, by tricking the user onto his site, and redirecting...
Read more >Microsoft identity platform access tokens
Clients must treat access tokens as opaque strings because the contents of the token are intended for the API only. For validation and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the funny part, is, that server just returns RS256 in header, but actually to valdate, it needs to be HS256, so if you change manually, and pack hader back to Base64 bit, chainging RS256 to HS265, validation passes
@jvandervelden I think I’m in the same boat as @fabien-h because I tried to validate the Access Token. I’m not using the Graph API, I have my own API which serves protected data, and a Javascript SPA which calls the API to shows data to user.
So I was sending the Access Token as a Bearer in the Authorization header. I tried to validate this access token by calling https://login.microsoftonline.com/common/discovery/keys (or the one with my tenant) and extracting the public key. Unfortunately there is a special treatment made on the nonce in header of the access token which makes it not valid with the public key provided.
What I may have misunderstood, is that I should not use the access token for my own API, but the id token instead. If i refer to this doc : https://docs.microsoft.com/en-us/azure/active-directory/develop/single-page-application , it’s stated :
So in my case should I use the id token ? If so, the docs here https://docs.microsoft.com/en-us/azure/active-directory/develop/id-tokens is kind of confusing :