After validating: 401: Client ID and OAuth token do not match

Hello,

Firstly, I’m going to prefix this message by saying, “I’m not a programmer; merely a hobbyist”. So please be gentle. I just hope I’m not doing something completely crazy.

So my issue if I’m getting an error after trying to use my access token when using users.

Here’s what I’m doing…

I’m validating my oauth token with this:

{ url: 'https://id.twitch.tv/oauth2/validate',
  method: 'GET',
  headers:
   { client_id: 'bt5v6ewrxkgfs8ewy1k3bl98zxkzj4e',
     Authorization: 'OAuth <my oauth token is here>' } }

I then get this response:

{"client_id":"bt5v6ewrxkgfs8ewy1k3bl98zxkzj4e","login":"dodgyblaster","scopes":["user:read:email"],"user_id":"136678973","expires_in":0}

I then validate the app token with this:

{ url: 'https://id.twitch.tv/oauth2/validate',
  method: 'GET',
  headers:
   { client_id: 'bt5v6ewrxkgfs8ewy1k3bl98zxkzj4e',
     Authorization: 'OAuth <my app token is here>' } }

I get this response:

{"client_id":"bt5v6ewrxkgfs8ewy1k3bl98zxkzj4e","scopes":["user:read:email"],"expires_in":5092880}

But when I go to use that app token with this:

{ url: 'https://api.twitch.tv/helix/users',
  method: 'GET',
  headers:
   { client_id: 'bt5v6ewrxkgfs8ewy1k3bl98zxkzj4e',
     Authorization: 'Bearer <my app token same as the above>' },
  qs: { id: 136678973 } }

I get this error response:

{"error":"Unauthorized","status":401,"message":"Client ID and OAuth token do not match"}

I’m clearly doing something wrong. But I’m not sure what.

Thanks in advance,

Dan

An app access token with scopes is useless it doesn’t represent a user. Just a side note

But that URL you are calling looks correct, as you are request a direct user, you just won’t ever get an email address, as the example call you provided is for an App Access Token, however,

Should be

‘client-id’: ‘bt5v6ewrxkgfs8ewy1k3bl98zxkzj4e’,

The Client ID header for the Twitch API is client-id not ‘client_id’ So you didn’t send a valid client-id header with your request

1 Like

Doh!

{ url: 'https://api.twitch.tv/helix/users',
  method: 'GET',
  headers:
   { 'client-id': 'bt5v6ewrxkgfs8ewy1k3bl98zxkzj4e',
     Authorization: 'Bearer <my app token>' },
  qs: { id: 136678973 } }

Now returns:

{"data":[{"id":"136678973","login":"dodgyblaster","display_name":"DodgyBlaster","type":"","broadcaster_type":"","description":"","profile_image_url":"https://static-cdn.jtvnw.net/jtv_user_pictures/f85ee872-573d-4e9d-bb35-6e27b9cf19a3-profile_image-300x300.png","offline_image_url":"https://static-cdn.jtvnw.net/jtv_user_pictures/a8b0813d-34dc-4344-966b-31f1684addb4-channel_offline_image-1920x1080.png","view_count":1819}]}

Thank you so much @BarryCarlyon for you time and advice.

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