A Microsoft Entra access token shows Invalid Signature when you check it yourself
Invalid SignatureShort answer
A token issued for Microsoft Graph is not meant for you to validate, so a failed signature check is expected. If the token is for your own API, the usual error is using the wrong key set: the keys must come from the metadata for the token's version, selected by its kid.
Fix it fast
1Find out which cause you have
Decode the token header and payload and read aud, ver and kid. They decide which cause applies.
echo "$ACCESS_TOKEN" | cut -d. -f1,2 | tr '.' '\n' | tr '_-' '/+' | while read p; do echo "$p==" | base64 -d 2>/dev/null; echo; done2Match what you see, then jump to its fix
What does the error look like?
Invalid SignatureTokens that a Microsoft API receives might not always be a JWT that can be decoded
Cause 1 of 2
The token was issued for Microsoft Graph, not for your API
1Check
Read the aud claim. Tokens for Microsoft-owned APIs follow their own proprietary format, and the docs say you cannot validate Graph tokens by the normal rules. Validating a token meant for another resource also leads to the confused deputy problem.
echo "$ACCESS_TOKEN" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null | grep -o '"aud":"[^"]*"'2Fix
Register your own API in Entra, expose a scope, and have the client request that scope. The token then carries your API as aud, and your API can validate it.
scope=api://<your-api-client-id>/access_as_user3Verify
Decode the new token: aud now shows your API, and its signature validates against your tenant's keys.
echo "$ACCESS_TOKEN" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null | grep -o '"aud":"[^"]*"'Confirmed by learn.microsoft.com
Cause 2 of 2
The keys were fetched from the wrong metadata document
1Check
A v1.0 token (ver 1.0) must be checked against the v1.0 metadata document, and a v2.0 token against the v2.0 one, whatever authority your API is configured with. Keys are rotated, so pick the key whose kid matches the token header, and use the application-specific keys URL if custom signing keys are in use.
curl -s https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration | grep jwks_uri2Fix
Point your validator at the metadata endpoint that matches the token version and let the library refresh keys; do not paste one certificate into the config.
# v2.0 tokens
https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration
# v1.0 tokens: remove /v2.0
https://login.microsoftonline.com/<tenant-id>/.well-known/openid-configuration3Verify
Fetch the jwks_uri from that document and check that a key with the token's kid is listed.
curl -s <jwks_uri> | grep <kid>Confirmed by learn.microsoft.com
How do I stop it coming back?
- Let a library such as Microsoft.Identity.Web or your framework's resource server validate tokens; do not hand-roll signature checks.
- Only validate tokens whose aud is your own API.
- Never debug production tokens on a public website; use a local decoder.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Security
Spring Security rejects the Entra ID token: invalid claims
Error occurred while attempting to decode the Jwt. The ID Token contains invalid claims
Spring checks the ID token's claims against your client registration.
3 causes, each with a fixSecurity
Azure Databricks REST API returns 403 with a Microsoft Entra token
Error 403 User not authorized when calling the Azure Databricks API
A 403 means the token was accepted but the identity in it is not allowed in that workspace.
4 causes, each with a fixSecurity
DelegateAuthenticationProvider no longer exists in the Microsoft Graph .NET SDK
The type or namespace name 'DelegateAuthenticationProvider' could not be found
Microsoft Graph .NET SDK v5 removed DelegateAuthenticationProvider.
3 causes, each with a fixSecurity
Jwts.parserBuilder() no longer compiles after upgrading JJWT
setSigningKey / parseClaimsJws / getBody shown as deprecated
JJWT 0.12.0 removed Jwts.parserBuilder() because Jwts.parser() now returns the builder itself.
3 causes, each with a fixSecurity
Spring Boot cannot find a ClientRegistrationRepository bean for OAuth2 login
APPLICATION FAILED TO START
Boot creates the ClientRegistrationRepository from spring.security.oauth2.client.registration properties.
3 causes, each with a fixSecurity
Spring resource server: 'An error occurred while attempting to decode the Jwt'
An error occurred while attempting to decode the Jwt: Malformed Jwk set
The resource server downloaded something from jwk-set-uri that is not a valid JWK Set.
2 causes, each with a fix