400 bad request from POST request

You’ve posted screenshots, not code, and the bit of code I’m interested in is off to the right of the screenshot.

client_credentials is a different kind of token, so the POST request behaves different

Without the body of the response, I have no idea what the actual bug/problem is, I would guess the code is invalid, or was attempted to be used twice. Which the body response would tell you which.

Since you seem to be fetching code from session (sessioncode in “English” sounds wrong hence asking to see the code) when code should be fetched from query string parameters, so this sounds like a double code usage, and the second one fails as it’s already been exchanged.

User oAuth works as follows

  1. Redirect the user to twitch
  2. User comes back with a ?code in the URL
  3. You exchange the ?code for a token.

I’m not sure what you are doing here, since you posted screenshots of responses rather than the code.