Twitch OAUTH2 implementation: "Client ID is missing"

So which step is falling.

The POST to exchange a code for a token.
Or the call to users

I see no reference in your post to the code to toke exchange.

See Use the authorization code to get a token in the Getting OAuth Access Tokens | Twitch Developers

So to be clear

  • Step 1 Send the user to twitch - you are doing this step
  • Step 2 the user accepts (or declines) the account link - users are doing this step
  • Step 3 user is redirected to your callback URL with a ?code=
  • Step 4 exchange the ?code= for a token via a POST to https://id.twitch.tv/oauth2/token
  • Step 5 you should now have a response with an access token
  • Step 6 call users with your clientID and access token.

This “one page” example in PHP covers this flow - https://github.com/BarryCarlyon/twitch_misc/blob/main/authentication/user_access_generator/php/index.php

Step 1 is line 151 in the template which generates the URL
Step 3/4 is line 32 is the code to token exchange (this then self redirects to itself if successful to remove ?code from the URL to avoid F5 issues as code is one use)
Step 5 line 62 is the token storage into session
Step 6 linne 85 is token validate and users call.

In summary, you have an error, but you didn’t log which steps has failed.

Is is the code to token or the users API call?

oAuth URL’s are client_id
oAuth exchange is client_id
Headers in the /users/ call is client-id