Api.twitch.tv/kraken/channels/:channel/follows - "The current authorization is not valid for this context"

Hello!

When i try to get followers of a channel i receive 403 error with message “The current authorization is not valid for this context”.

1.I authorize with all the possible permissions:
https://api.twitch.tv/kraken/oauth2/authorize?client_id=:my_id&redirect_uri=:my_uri&response_type=token&scope=:scopes

:scopes is channel_check_subscription+channel_commercial+channel_editor+channel_feed_edit+channel_feed_read+channel_read+channel_stream+channel_subscriptions+chat_login+collections_edit+communities_edit+communities_moderate+openid+user_blocks_edit+user_blocks_read+user_follows_edit+user_read+user_subscriptions+viewing_activity_read

2.I get redirected to my URI with this attributes:
http://my_uri/#access_token=:token&scope=:scopes&token_type=bearer

3.Then i copy the token and check if the token is valid. As i use Chrome i can use Postman to send requests. I open Postman, enter https://api.twitch.tv/kraken URL, select GET type, adding first header with key “Accept” and value “application/vnd.twitchtv.v5+json”, adding the second header with key “Authorization” and value “OAuth :token”, send the request and receive this answer:

Summary
{
    "identified": true,
    "token": {
        "valid": true,
        "authorization": {
            "scopes": [
                "channel_check_subscription",
                "channel_commercial",
                "channel_editor",
                "channel_feed_edit",
                "channel_feed_read",
                "channel_read",
                "channel_stream",
                "channel_subscriptions",
                "chat_login",
                "collections_edit",
                "communities_edit",
                "communities_moderate",
                "openid",
                "user_blocks_edit",
                "user_blocks_read",
                "user_follows_edit",
                "user_read",
                "user_subscriptions",
                "viewing_activity_read"
            ],
            "created_at": "2017-07-08T15:07:06Z",
            "updated_at": "2017-07-08T15:07:06Z"
        },
        "user_name": "lazalu68",
        "client_id": "l1tb7o787s8csl7azddcb4ri08w2d1"
    },
    "_links": {
        "channel": "https://api.twitch.tv/kraken/channel",
        "chat": "https://api.twitch.tv/kraken/chat/lazalu68",
        "teams": "https://api.twitch.tv/kraken/teams",
        "user": "https://api.twitch.tv/kraken/user",
        "users": "https://api.twitch.tv/kraken/users/lazalu68",
        "streams": "https://api.twitch.tv/kraken/streams/lazalu68",
        "ingests": "https://api.twitch.tv/kraken/ingests",
        "channels": "https://api.twitch.tv/kraken/channels/lazalu68"
    }
}

I think it means that the token is valid.

4.Then i try to get all subscriptions of a channel, goldensplit for example. I do the same: open Postman, enter https://api.twitch.tv/kraken/channels/goldensplit/subscriptions URL, create headers - Accept for v5, Authorization with OAuth :token as value and Client-ID. When i send request i receive 404 with message “Channel ‘goldensplit’ does not exist”. Maybe i should pass a channel ID, not a login? Ok, i execute a request to https://api.twitch.tv/kraken/users?login=goldensplit, get his id (90810861), and then send a request to https://api.twitch.tv/kraken/channels/90810861/subscriptions, but i get 403 with message “The current authorization is not valid for this context”.

I can read, but what does it mean? Why can’t i get the subscriptions though i requested all the possible permissions?

Looking at the summary, your token is for the user ‘lazalu68’, not goldensplit. The token may have all the scopes (generally you should only request the specific scopes your app needs), but they’re not for the channel you’re trying to use the API with.

I don’t get it, actually. As the manual says, a token grants an access to some features, for example with token you can get a list of users subscribed to a specified channel. If i try to get subscribers of channel with ID 129454141 i get this:

{
    "error": "Unprocessable Entity",
    "status": 422,
    "message": "dallasnchains does not have a subscription program"
}

Ok, if i do it wrong, how do i get all the subscribers of a specified channel?

You need a token authorized by that channel’s owner. You need goldensplit’s authorization to get goldensplit’s subscribers.

You mean i’m only able to retrieve my own subscribers?

I don’t believe it, there’s nothing in docs about it.

Did you expect to be able to access the private information, stream keys, subscribers, edit channel details and much more of every single person on Twitch just by generating an OAuth token using your own account? No, If you want to access those things of someone else then you need their permission by having them go through your apps authentication process so that you have an OAuth token for that specific user with the scopes you’ve specified.

No, i understand that i need a special permission to edit channel details.

Ok, why do you call subscribers list the private information, isn’t it public? If not, why? What’s special about subscribers that distincts them from followers?

Real money is involved with subscriptions, unlike followers. The API gives details such as the total number of subs, what sub tier each of them is on and when each entry was created. Not all streamers (or Twitch) want everyone to have access to that information. Some streamers may be willing to talk about the sub count, or numbers of subs at the various tiers, but some (from my experience, most) streamers will want to keep that information private, or limit access to it to only the apps that they choose to give access to.

If you have a legitimate need to access subscriber information of a streamer, ask the streamer. If they say no then you’re out of luck, you have no business accessing those details.

Oh, real money. This makes sense. Seems i just have not enough information about twitch.

So, it’s impossible for an app to get a list of some other channel subscribers, only followers?

Anyway, why there’s nothing about it in docs? As a web dev i have no understanding of some twitch specific things, and i thought it’s kinda basic function to get all the subscribers.

I got it, thanks.

The docs do mention how tokens are used. specifically the Authentication page. It mentions that the tokens give you the ability to take action or access data on behalf of that users account.

OAuth 2 is not a Twitch specific thing, it’s a widely used framework and worth reading up on as many other web services work in a similar way.

1 Like

I didn’t mention authentication system, also i had no problems with it.

Twitch specific is subscribers system. It is specific because REST says that if entities of some kind can’t have more than one source, then you shouldn’t make your clients to specify this source in their queries.

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