54005 error

jun xiang 1 Reputation point
2021-03-19T01:31:04.42+00:00

I use the https://login.microsoftonline.com//{tenant}/oauth2/v2.0/token API to obtain tokens. It has been running well, but recently it often appears intermittently inaccessible.
The error message is as follows:
{"error":"invalid_grant","error_description":"AADSTS54005: OAuth2 Authorization code was already redeemed, please retry with a new valid code or use an existing refresh token.\r\nTrace ID: 01c12a0a-c622-48c2-90a0 -9c1d81488f00\r\nCorrelation ID: b1b1e359-6654-49dd-82a7-9be1bbdb48ed\r\nTimestamp: 2021-03-18 01:32:40Z","error_codes":[54005],"timestamp":"2021-03 -18 01:32:40Z","trace_id":"01c12a0a-c622-48c2-90a0-9c1d81488f00","correlation_id":"b1b1e359-6654-49dd-82a7-9be1bbdb48ed"}
What caused this? By the way, I am from China.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,618 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deva-MSFT 2,256 Reputation points Microsoft Employee
    2021-03-19T16:44:46.407+00:00

    Make sure that you should call AcquireTokenByAuthorizationCodeAsync only once when you receive authorization code. Also you made need to call OAuth2 authorize endpoint with offline_access scope to get refresh token.

    0 comments No comments