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?

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
14,876 questions
A Microsoft file hosting and synchronization service.
303 questions
Microsoft Graph SDK
Microsoft Graph SDK
A Microsoft software developer kit designed to simplify building high-quality, efficient, and resilient applications that access Microsoft Graph.
889 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 15,066 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