How to solve InvalidAuthenticationToken error

Dhruvin Moradiya 55 Reputation points
2023-03-09T06:09:21.9133333+00:00

I have created an app in Azure and given the below permissions to Microsoft Graph.

  • APIConnectors.Read.All
  • Files.Read
  • Files.Read.All
  • Files.ReadWrite.All
  • offline_access
  • User.Read

https://graph.microsoft.com/v1.0/me/drive/root/children. I'm making a GET request to list files and folders in one drive root folder. But I'm getting the below error.

{
    "error": {
        "code": "InvalidAuthenticationToken",
        "message": "Access token validation failure. Invalid audience.",
        "innerError": {
            "date": "2023-03-09T06:01:36",
            "request-id": "0e614c70-c557-4599-8707-8351352cfcbd",
            "client-request-id": "0e614c70-c557-4599-8707-8351352cfcbd"
        }
    }
}

Am I doing anything wrong here?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,229 questions
{count} votes

Accepted answer
  1. CarlZhao-MSFT 42,211 Reputation points
    2023-03-09T06:27:01.34+00:00

    Hi @Dhruvin Moradiya

    This indicates that the API audience of your access token is inconsistent with the API endpoint you are calling.

    When you get an access token, you should set the values of Scope, Auth URL, Access Token URL to:

    Scope: https://graph.microsoft.com/.default offline_access

    Auth URL:https://login.microsoftonline.com/common/oauth2/v2.0/authorize

    Access Token URL:https://login.microsoftonline.com/common/oauth2/v2.0/token

    User's image

    Call the Graph API:

    User's image

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.