{Solved} Access Token validation error. Invalid Audience – Graph API Error

Hello everyone and welcome to my blog. In today’s blog I will discuss about a common error you may encounter while connecting to SharePoint or OneDrive using Graph API and how to resolve the same.

When using Graph API, you may encounter the below error. Pic courtesy: Microsoft Learn.

The error happen precisely because of issues when generating the token. And when you use the bearer token to fetch data, you encounter this error.

The first and the foremost thing is to make sure you are using the right URL to generate the token, The URL should be the following.

https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/token

Frequently this is mistaken with the below URL. While you will get the token using the below URL too, when you use the below URL to generate the token, it will lead to the error discussed here.

https://login.microsoftonline.com/{tenantid}/oauth2/token.

If you are using the right endpoint and still receiving the above error, cross check the value of the scope parameter in token generation request.

The scope should be https://graph.microsoft.com/.default as shown in the above screenshot.

If you have checked all these boxes during token generation, you should no longer be getting Access Token validation error. Invalid Audience.

Hope you liked this post. If this post has helped, you can buy me a coffee.

For similar topics on Microsoft.NET and Power Platform, subscribe to my blog using the Subscribe option on right pane.

You will also like the below posts.

Debajit Dutta
Business Solutions MVP