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

Mridul Kapil 0 Reputation points

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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,315 questions
A Microsoft file hosting and synchronization service.
950 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,444 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 29,441 Reputation points Microsoft Employee

    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.



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

    0 comments No comments