ok, so i have a method to getting a new twitch token through code, it looks like this
const url = "https://id.twitch.tv/oauth2/token?client_id=TWITCH_ID&client_secret=TWITCH_SECRET&grant_type=client_credentials&scope=channel:read:subscriptions"
const res = await axios.post(url);
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:
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
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
- Generate a URL
- Redirect the user to that URL
- They accept (or decline) allowing access to their account to your Client ID
- They return to your website with a code (or error message)
- 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.