Tons of Bad Request responses on id.twitch.tv auth, for no apparent reason

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:

  1. 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.
  2. 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?

I’ve changed the retry delay to 500ms, but still getting a considerable amount of Bad Request responses.

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