Invalid_grant exception while refreshing a token

I’m getting {error: ‘invalid_grant’, reason: ‘Invalid Token!’} as a response to the /oauth/token?grant_type=refresh_token&refresh_token=<refresh_token> request.

we use refresh token api in our code to generate a new token whenever a token gets expired for a user, it gave me this error only in one request so I wants to know the possible reason behind that because grant_type is similar in all the requests which is ‘refresh_token’ so in what case this api can give ‘invalid_grant’ error?

Welcome, @agoel3,

Thank you for posting in the Developer Forum. Generally, the “Invalid Token” error happens when the latest refresh token is not used when generating a new Access token. Before diving further, can tell us if this only happening to one particular user or more ? Also, how frequently are you seeing this behavior?

Regards,
Donte

This error is breaking all application for our clients as well, so I guess it’s not specific to an application. It is also seen here: Invalid Token! (invalid_grant) when trying to renew a token on our app - #4 by basic

Is there a proposed fix for this issue?

Figured it out, the refresh token is one time use, after using it to fetch access token once, the refresh token will be returned as well as the new refresh token.

Glad to hear you were able to resolve this and you found that post useful. You are correct! While a refresh token is valid for 15 years, it can only be used once. I’ve linked our help documentation below for reference:

Refreshing an Access Token

So Iet’s say one of fetch access token api gets timeout due to some network issues, Is there a way to get the new access token (using rest apis only without manual reauthorisation) because in that case we won’t have the new refresh token.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.