i007.cc

i007.cc

优先队列-降维打击

05.价值资料

How to solve InvalidAuthenticationToken error

cc from

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 Files API
 {count} votes

 Accepted answer
  1. CarlZhao-MSFT27,206Reputation points
    Mar 9, 2023, 2:27 PM

    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 ScopeAuth URLAccess 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.


发表回复