Invalid refresh_token when i try to refresh

hi, i have a problem.
when i try to refresh an access token i get
{“status”:400,“message”:“Invalid refresh token”}

i am using laravel and therefore php
this is the request I make

    $query = '';

    $result = Http::withHeaders(



        'grant_type' => 'refresh_token',

        'refresh_token' => urlencode($refresh_token),

        'client_id' => $this->client_id,

        'client_secret' => $this->client_secret


this used to work correctly now this problem occurs from time to time for no apparent reason
if I connect the twitch account again for a short time it will work again

can you help me?

If it works some of the time, it sounds like you’re not storing the new refresh token each time and attempting to use the old refresh token which may work initially but if the refresh tokens change it’ll fail.

1 Like

hi, thanks for the reply
when I get a new access token I already check if the refresh token has changed and save the new one.
I try to see if there is an error in saving in the database

i tried to refreshare the token several times to see if the refresh_token changed this is the result

{“status”:400,“message”:“Invalid refresh token”}

as you can see the refresh token always remains the same but becomes invalid

There are other cirteria that can killed a refresh token.

If you generate 25 brand new tokens, (access token/refresh token pair by clientID)
When you generate the 26th it’ll kill the first set.

This might be what is happening here.

But since there is never a reason given for a dead refresh token, it could be a bunch of different things

1 Like

hi thanks for your reply
is there a page in the documentation that lists the possible reasons?


im having the same issue. i too am saving the new refresh token and cant find anything wrong with my flow

I’ve validated that the reasons @BarryCarlyon has listed are not the culprits

1 Like

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