Entra ID sign-in error

AADSTS54005: Authorization code already redeemed

AADSTS54005 means the app tried to redeem the same authorization code twice. Why frameworks cause it and how to stop the second redemption.

Last updated Checked against Microsoft Learn on Look up another code

AADSTS54005

Tokens, sessions and requestsWho fixes it:App developer

OAuth2 Authorization code was already redeemed, please retry with a new valid code or use an existing refresh token.

Microsoft's description, from the Microsoft Entra error code reference

What it means

The app tried to redeem the same authorization code a second time. A code can be exchanged for tokens only once. A common cause is a framework or library that redeems the code automatically while the app's own code redeems it again.

Fix it: app developers

  1. Redeem each authorization code once. For another token, start a new sign-in to get a new code, or use the refresh token you already have.
  2. In ASP.NET or ASP.NET Core with MSAL, call context.HandleCodeRedemption() in the AuthorizationCodeReceived event so the framework does not redeem the code again.
  3. Codes are short-lived, typically about a minute, so do not cache or replay them.

Fix it: the person signing in

  1. Starting the sign-in again gives the app a new code, which is what Microsoft's message asks for. If the error comes back, the app needs fixing: report it to its support team.

Related codes

Microsoft sources

Find who is hitting AADSTS54005

Sign-in logs record the code without the AADSTS prefix: as status/errorCode in Microsoft Graph S04 and as ResultType in the SigninLogs table in Log Analytics S05. The SigninLogs and Microsoft Graph queries below cover interactive sign-ins. Non-interactive sign-ins are in the AADNonInteractiveUserSignInLogs table, which documents the error code in ResultSignature S41. If you query that table, test ResultType as well. For one failed sign-in, paste its error message into the lookup to get queries for its Correlation ID.

Log Analytics (KQL), last 7 days

SigninLogs
| where TimeGenerated > ago(7d) and ResultType == "54005"
| summarize Failures = count(), Last = max(TimeGenerated) by UserPrincipalName, AppDisplayName
| sort by Failures desc

Microsoft Graph PowerShell, last 7 days

Connect-MgGraph -Scopes "AuditLog.Read.All"
$since = (Get-Date).ToUniversalTime().AddDays(-7).ToString("yyyy-MM-ddTHH:mm:ssZ")
Get-MgAuditLogSignIn -Filter "status/errorCode eq 54005 and createdDateTime ge $since" -All |
  Select-Object CreatedDateTime, UserPrincipalName, AppDisplayName, CorrelationId

Reading sign-in logs needs at least the Reports Reader role S06; the Graph call needs the AuditLog.Read.All permission S42, and -All returns every page of results S69.

Sources for this page

Microsoft's description is quoted from the Microsoft Entra error code reference; it is Microsoft's text and is not covered by our CC BY 4.0 licence. The cause and fix steps are our own wording, published under CC BY 4.0; each source below is the Microsoft page they rest on, with the passage we checked. Rules for every page are in the methodology.

  1. S01. Microsoft (Microsoft Learn), Microsoft Entra authentication and authorization error codes. Retrieved 2026-11-25.

    OAuth2 Authorization code was already redeemed, please retry with a new valid code or use an existing refresh token.

    Error codes are subject to change at any time in order to provide more granular error messages

    Error codes and messages are subject to change. For the most current info, take a look at the

    You can also link directly to a specific error by adding the error code number to the URL

  2. S31. Microsoft (Microsoft Learn), Authentication flow support in MSAL. Retrieved 2026-11-25.

    The OAuth 2.0 specification requires you use an authorization code to redeem an access token only once.

    Keep in mind that some libraries and frameworks request the authorization code for you automatically, and requesting a code manually in such cases will also result in this error.

  3. S32. Microsoft (Microsoft Learn), Authorization codes (MSAL.NET). Retrieved 2026-11-25.

    this might happen if you don't tell the ASP.NET/Core framework that you have already redeemed the code. For this you need to call context.HandleCodeRedemption()

  4. S22. Microsoft (Microsoft Learn), Microsoft identity platform and OAuth 2.0 authorization code flow. Retrieved 2026-11-25.

    Authorization codes are short lived. Typically, they expire after about 1 minute.

  5. S04. Microsoft (Microsoft Learn, Microsoft Graph), signIn resource type. Retrieved 2026-11-25.

    Supports $filter (eq) on errorCode property.

    The request ID sent from the client when the sign-in is initiated. Used to troubleshoot sign-in activity.

  6. S05. Microsoft (Microsoft Learn, Azure Monitor), Azure Monitor Logs reference - SigninLogs. Retrieved 2026-11-25.

    Provides the 5-6 digit error code that's generated during a sign-in event. 0 indicates success; other values are failures.

    The identifier that's sent from the client when sign-in is initiated.

  7. S06. Microsoft (Microsoft Learn), How to troubleshoot sign-in errors. Retrieved 2026-11-25.

    Reports Reader is the least privileged role required to access the activity logs.

    any user can access their own sign-ins from https://mysignins.microsoft.com.

  8. S41. Microsoft (Microsoft Learn, Azure Monitor), Azure Monitor Logs reference - AADNonInteractiveUserSignInLogs. Retrieved 2026-11-25.

    Contains the error code, if any, for the sign-in operation.

  9. S42. Microsoft (Microsoft Learn, Microsoft Graph), List signIns. Retrieved 2026-11-25.

    To avoid having the request time out, apply the $filter parameter with a time range for which to get all sign-ins

    Sign-ins that are interactive in nature

  10. S69. Microsoft (Microsoft Learn, Microsoft Graph PowerShell), Get-MgAuditLogSignIn (Microsoft.Graph.Reports). Retrieved 2026-11-25.

    -All List all pages.

Back to the AADSTS Error Code Lookup · All 351 codes