Niru
Niru

Reputation: 91

Invalid audience claim in token The JSON Web Token (JWT) used as a token does not have the correct audience. Ensure you are using the correct token

Unable to authenticate against a backend api using Azure. Error says invalid audience but the aud claim had the backend api client id when troubleshooting in jwt.ms.

Upvotes: 5

Views: 24690

Answers (1)

Carl Zhao
Carl Zhao

Reputation: 9559

From your error report, it is indeed a 401 error, that is, your audience does not match the api you want to call, but your parsing token aud claims to have the backend api client ID, so I think your authentication There may be a problem with the configuration, I use the auth code flow to do a simple demonstration for you:

enter image description here

Next,under 'API permissions', give your front-end application access to your backend api:

  • Under 'API permissions' click on 'Add permission', then click on the 'My APIs' tab.
  • Find your backend application and select the appropriate scope.
  • Click 'Add permissions'.
  • Grant admin consent for your APIs.

enter image description here

Get token:

enter image description here

Parse the token:

enter image description here

Upvotes: 3

Related Questions