I have created page for ‘connect to twitch’ button, Using it for authenticating user, then send to redirect
uri which is created in app. Till here I have done it using ‘Implicit Grant Method’ of authentication method. Now after this I have to check for user subscription, if user has already subscribed to the channel then move to teamspeak info if not then to subscription page.
But I am not getting user subscription info. I have tried with this
https://api.twitch.tv/kraken/users/test_user/subscriptions/test_channel and also with
https://api.twitch.tv/kraken/subscribed?oauth_token= [token generated]
but it is giving invalid token error .
Please guide me what wrong I am doing in it?
Make sure you have authenticated with the scope user_subscriptions
.
You can always check the current scope with the Root /
endpoint:
https://github.com/justintv/Twitch-API/blob/master/v2_resources/root.md#get-
thanks for your reply Subspots.
I am using user_read and user_subscriptions both in the scope. But won’t get results.
below displayed is result which I get
url: api.twitch.tv/kraken/user?oauth_token=7vu4yscpol8l1s6dh2acqbv4k9apc3b&scope=user_read+user_subscriptions
url: https://api.twitch.tv/kraken/subscribed?oauth_token=7vu4yscpol8l1s6dh2acqbv4k9apc3b
stdClass Object
(
[error] => Not Found
[status] => 404
[message] =>
)
url: https://api.twitch.tv/kraken/channels/imcoty/subscriptions/archonfreak
stdClass Object
(
[error] => Unauthorized
[status] => 401
[message] => Token invalid or missing required scope
)
i tried with different urls which is given in api for getting user’s subscription. but both above url giving 404 and 401 error status.
can you please post any example where you have used it ?
george
September 27, 2014, 5:13pm
4
Since you are authenticated as “archonfreak” and not the channel owner “imcoty” you will have to use the user subscription end point: GET /users/:user/subscriptions/:channel
For example, using the oauth token you supplied in your post: https://api.twitch.tv/kraken/users/archonfreak/subscriptions/imcoty?oauth_token=7vu4yscpol8l1s6dh2acqbv4k9apc3b
vs a channel (lirik) you are not subbed to:
https://api.twitch.tv/kraken/users/archonfreak/subscriptions/lirik?oauth_token=7vu4yscpol8l1s6dh2acqbv4k9apc3b
Thanks George. You solved my issue.