I have registered an App on my Entra ID (just created as an empty placeholder, NOT connected with an azure resource like an app service; only audience: Microsoft.Graph) and I successfully retrieved a token using postman.
I have a spring boot application, running locally on my pc, that expose an API; as a test, I'm trying to "protect" programmatically this API using the jwt token from Entra:
My auth config
For the key I'm using the modulus, exponent and encryption (RSA) retrieve from jwt.io, but still the code gave me an error of invalid token (trying the same thing with the token from the other Identity provider works fine).
Note that: The access token with aud as Microsoft Graph is not meant to be validated.
When I tried to validate the Microsoft Graph API token, I got the same error:
I generated access token with scope as https://graph.microsoft.com/.default
Hence pass the token directly without validating it and call the Microsoft Graph API.
If you want to validate the API, then add scope:
And add API permissions like below:
Generated the access token by using scope as api://ClientID/.default
:
Signature verified successfully
Reference:
spring security - Verify Signature with Azure AD - Stack Overflow by junnas