How to generate access token using OAuth for Owner of an Azure Directory?

Mridul Kapil 0 Reputation points
2023-05-26T04:51:11.22+00:00

I created an application using Graph API to sign-in using OAuth web-server flow. It is working fine for personal users and the members of that directory but when I am trying to login using the Owner of a directory, it is throwing me an error saying -

{"error":"invalid_grant","error_description":"The provided value for the 'code' parameter is not valid. The code has expired.","correlation_id":"1ee5a7a0-50c9-4767-a64c-4d79b679bdfb"}



What should be the issue as Supported account types contain AzureADandPersonalMicrosoftAccount values?

Microsoft 365 and Office | OneDrive | For business | Windows
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 30,301 Reputation points Microsoft Employee Moderator
    2023-05-26T06:16:13.8333333+00:00

    Hi @Mridul Kapil ,

    Thanks for reaching out.

    The error you are getting is due to the "authorization code" to exchange the access token has been used once or expired. Authorization codes are short lived. Typically, they expire after about 10 minutes and can be used once only to redeem the accesss token.

    Did you try with fresh "authorize code" to authenticate the user?

    Hope this will help.

    Thanks,

    Shweta


    Please remember to "Accept Answer" if answer helped you.

    0 comments No comments

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.