54005 error

jun xiang 1 Reputation point

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

    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