coreos / go-oidc

A Go OpenID Connect client.
Apache License 2.0
1.92k stars 393 forks source link

Getting AADSTS54005: OAuth2 Authorization code was already redeemed #427

Closed Jarecamang closed 4 months ago

Jarecamang commented 4 months ago

Hi folks, I'm getting an error:

failed to exchange token: oauth2: cannot fetch token: 400 Bad Request Response: AADSTS54005: OAuth2 Authorization code was already redeemed, please retry with a new valid code or use an existing refresh token.

I'm getting this error while using pretty much the same solution you use in your readme, and it is failing when I try to Exchange the code query param to get the oauth2Token oauth2Token, err := config.Exchange(ctx, c.QueryParam("code")) I'm seeing this error only on a couple of my webpage users, not in all, and I've read a couple of solutions that say that I need to use a refresh token, however, from the client side, I don't think I can do that. Any suggestion or insight would be highly appreciated.

ericchiang commented 4 months ago

Sorry, this both seems like an issue with golang.org/x/oauth2 and you'll probably need to consult with your provider. This isn't something in this packages code