How to solve InvalidAuthenticationToken error

Narender Singh Pawar 0 Reputation points
2024-09-12T03:29:16.7033333+00:00

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

  • Files.Read.All
  • Files.ReadWrite.All

User's image

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,273 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,827 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,273 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Hitesh Pachipulusu - MSFT 3,000 Reputation points Microsoft Vendor
    2024-09-12T06:14:30.23+00:00

    Hello Narender Singh Pawar,

    Thank you for contacting Microsoft Support!

    The “InvalidAuthenticationToken” error typically occurs when the access token used in your request is invalid or not properly configured. Here are some steps to help you resolve this issue:

    1. Check Token Validity: Ensure that the access token is valid and not expired. You can use tools like JWT.io to decode and verify the token.
    2. Correct Scopes: Make sure that the token includes the correct scopes for the permissions you have granted. For example, your token should include Files.Read.All and Files.ReadWrite.All.
    3. Consent: Ensure that the necessary permissions have been consented to by an administrator if required.
    4. Access Token in Header: Make sure that the access token is included in the HTTP Authorization header of your request as a Bearer token.

    Please check documentation and follow the steps provided. Use Postman with the Microsoft Graph API

    Hope this helps.

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


  2. Narender Singh Pawar 0 Reputation points
    2024-09-12T06:27:20.2533333+00:00

    @Hitesh Pachipulusu - MSFT ya actually it worked but now I am facing this problem.

    {
        "error": {
            "code": "UnknownError",
            "message": "Unable to retrieve user's mysite URL.",
            "innerError": {
                "date": "2024-09-12T06:24:18",
                "request-id": "a8943841-af34-4ee4-9023-8668e9de6bcf",
                "client-request-id": "a8943841-af34-4ee4-9023-8668e9de6bcf"
            }
        }
    }
    

  3. CarlZhao-MSFT 42,526 Reputation points
    2024-09-12T07:36:15.82+00:00

    Hi @Narender Singh Pawar

    I can reproduce your issue locally. This is because the target user lacks a valid MS 365 license. When you try to access MS 365 resources, an MS 365 license is necessary.

    Please contact your administrator to assign an MS 365 license to the user and then try again.

    5bf81d28-738d-47ee-9ba8-a4c1b2bc6462

    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.


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.