Twitter OAuth 2.0 Refresh Token Error - (invalid_request) Value passed for the token was invalid

I was running into this error while using Tweepy with OAuth 2.0 User Auth with PKCE when I tried to refresh the token via the User Handler. It was being returned when trying to call the non-production Tweepy refresh function on an expired token.

In my case, the issue was happening because I was trying to refresh the same token more than once. The solution is to refresh the expired token once and save the new token to a variable or your database until it needs to be refreshed again. Once refreshed once, the old token is no longer valid.

Back to Top