[invalid_id_token] An error occurred while attempting to decode the Jwt: The ID Token contains invalid claims

Akanksha Pandey 6 Reputation points
2022-06-08T06:12:05.837+00:00

I am adding oauth into an application(Java based) and I'm running into the following error:

209325-screenshot-94-li.jpg
I have followed all the steps to setup Azure AD using the offical documentation: https://learn.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory
I checked the validity of my token using Postman- it's working there.

I'm stuck since 2 days. Anyone please help

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,664 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Shweta Mathur 27,941 Reputation points Microsoft Employee
    2022-06-08T12:26:48.327+00:00

    Hi @Akanksha Pandey ,

    Thanks for reaching out.

    I understand you are looking to authenticate using Spring Boot Starter and getting error in the ID-Token.

    As per documentation you mentioned, this is basic lab to introduced spring boot classes and annotations.

    The error you are getting is due to invalid audience in the token. The audience of a token is the intended recipient of the token. In this particular documentation we are not calling any graph or protected API, so we are not specifying any scope in the application. Properties.

    If you are calling any Graph API or protected API after authenticating the user, then the valid scope needs to add in the application to access the API.

    eg scopes: https://graph.microsoft.com/User.Read need to add to access Graph API to read user details.

    Could you please confirm if you are passing any scope in your application or while authenticating using postman?

    I tried to replicate the given steps as mentioned in document in my lab and able to call message mentioned in controller successfully.

    209458-image.png

    Hope this will help.

    Thanks,
    Shweta

    ------------------------

    Please remember to "Accept Answer" if answer helped you.