Trying to get channel's subscriptions only gives error

ok, so i have a method to getting a new twitch token through code, it looks like this

const url = ""
const res = await;

and this gives me a token just fine, gives me the correct scopes.

but when I’m trying to get a channel’s subscriptions, it gives me this error:

      error: 'Unauthorized',
      status: 401,
      message: 'Invalid OAuth token'

what am I doing wrong? how do I do this?

client_credentials is not a valid token type to call subscriptions with*

You need a user access token

a client_credentials doesn’t represent a user so it doesn’t have authority to read subscribers

*unless it’s an extension clientID with sub capabilities enabled.

ok… so it gives me this example


so what do I set as the code header? it seems like it has something to do with the redirect uri, but since my application is just getting a channel’s information, it wont redirect users. what do I do here?

For regular user oAuth

  1. Generate a URL
  2. Redirect the user to that URL
  3. They accept (or decline) allowing access to their account to your Client ID
  4. They return to your website with a code (or error message)
  5. Exchange the code for an access token (using the post request you posted)

To get subscriber data you need permission from the broadcaster, which will require this “oAuth loop” to get delegated access.

ok so i need permission from the channel… is there a way to: instead of getting the list of subscribers of a channel, get the number of subs? because i want to be able to get the subscriber count of any channel. is this possible?


Subscriber data is “priviledged” information.

You require permission from the owner of that data to read that data.

ok, that makes sense. thanks for taking time to answer this, I appreciate it : )

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