I’m logging a ton of Bad Request responses when trying to generate a token from a code.
It works a lot of times, but other times it doesn’t.
When it doesn’t work I get a response with error “400”, and message “Invalid
authorization code”.
Why is the code returned as invalid?
I’ve made these steps to make sure it should work:
- I removed the code from the URL on load, so if a refresh happens by the user, the code won’t be sent more than once.
- I retry the request to id.twitch.tv/oauth2/token until it fails 5 times (with 50ms wait between retry requests)
I URL-encode the request params properly. But regardless, the code shouldn’t have any special characters in it. I’ve failed on codes that are just [a-z0-9] characters.
Could it be that I need to wait a while (>5s) before the code properly propagates on Twitch’s system?
Anyone have any clue why this happening?