Request: https://api.twitch.tv/kraken/channels/daggersoath/subscriptions
Headers: [Client-ID, Authorization (Bearer)]
Token scopes:[“channel:read:subscriptions”,“channel_subscriptions”]
token_type: bearer
When performing this request I get the response {"error":"Unauthorized","status":401,"message":"authentication failed"}
I feel like I am missing something obvious here but I can’t seem to find any info as to why this wouldn’t work?
Usually this sounds like you got an app access token
instead of a user access token
Documented:
Send user to Twitch (using response_type=code
)
Authorise access to account
Exchange code for token (and refresh token)
???
Profit
Send user to twitch with url:
https://id.twitch.tv/oauth2/authorize?client_id=<client-id>&redirect_uri=http%3A%2F%2Flocalhost&response_type=code&scope=channel%3Aread%3Asubscriptions+channel_subscriptions
Then taking the code from the redirect perform a post to:
https://id.twitch.tv/oauth2/token?client_id=<client-id>&client_secret=<secret>&code=<the-code>&grant_type=authorization_code&redirect_uri=http%3A%2F%2Flocalhost
Then perform the request to the channel using the returned “access_token”. Is that not the correct flow?
That is correct yes!
For kraken, it’s oAuth not Bearer. I missed you were calling kraken and tying to use “bearer”
headers: Authorization: oAuth <TOKEN>
Authentication
So using 'Authorization': 'OAuth <token>'
{“error”:“Unauthorized”,“status”:401,“message”:“missing required oauth scope”}
I can’t seem to find any scope “oauth”, (getting scope list from https://dev.twitch.tv/docs/authentication/#scopes )
Edit:
This was my mess up, I was using the wrong token here. It works now, thanks for your help
Requires channel_subscriptions
scope
kraken/v5 doesn’t return a useful error.
You can check the scopes a token has by calling
https://api.twitch.tv/kraken/
With the token
And additionally you need to be using the channel_id not the channel name
As v3 is “dead”
Problem solved, thank you for the assistance Can close the thread
1 Like
system
Closed
July 26, 2019, 2:13pm
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.