# Authentication failed trying to get channel subscribers

**URL:** <https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631>\
**Category:** API\
**Created:** [June 26, 2019, 1:33pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631 "2019-06-26T13:33:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![daggersoath](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/daggersoath/32/3754_2.png) [@daggersoath](https://discuss.dev.twitch.com/u/daggersoath)\
**Post date:** [June 26, 2019, 1:33pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631/1 "2019-06-26T13:33:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 26, 2019, 1:35pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631/2 "2019-06-26T13:35:06Z")

</div>

Usually this sounds like you got an `app access token` instead of a `user access token`

Documented:

> **[Getting OAuth Access Tokens](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-authorization-code-flow)**
>
> Getting OAuth Access Tokens

1. Send user to Twitch (using `response_type=code`)
2. Authorise access to account
3. Exchange code for token (and refresh token)
4. ???
5. Profit

---

<div class="post-metadata">

**Author:** ![daggersoath](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/daggersoath/32/3754_2.png) [@daggersoath](https://discuss.dev.twitch.com/u/daggersoath)\
**Post date:** [June 26, 2019, 1:43pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631/3 "2019-06-26T13:43:36Z")

</div>

Send user to twitch with url:  
`https://id.twitch.tv/oauth2/authorize?client_id=<client-id>&amp;redirect_uri=http%3A%2F%2Flocalhost&amp;response_type=code&amp;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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 26, 2019, 1:47pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631/4 "2019-06-26T13:47:56Z")

</div>

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](https://dev.twitch.tv/docs/authentication/#sending-user-access-and-app-access-tokens)**
>
> Authentication

---

<div class="post-metadata">

**Author:** ![daggersoath](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/daggersoath/32/3754_2.png) [@daggersoath](https://discuss.dev.twitch.com/u/daggersoath)\
**Post date:** [June 26, 2019, 2:07pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631/5 "2019-06-26T14:07:26Z")

</div>

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](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 🙂

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 26, 2019, 2:10pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631/6 "2019-06-26T14:10:49Z")

</div>

> **[Reference](https://dev.twitch.tv/docs/api/reference/)**
>
> Twitch Developer tools and services to integrate Twitch into your development or create interactive experience on twitch.tv.

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/](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”

---

<div class="post-metadata">

**Author:** ![daggersoath](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/daggersoath/32/3754_2.png) [@daggersoath](https://discuss.dev.twitch.com/u/daggersoath)\
**Post date:** [June 26, 2019, 2:13pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631/8 "2019-06-26T14:13:12Z")

</div>

Problem solved, thank you for the assistance 🙂 Can close the thread

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [July 26, 2019, 2:13pm UTC](https://discuss.dev.twitch.com/t/authentication-failed-trying-to-get-channel-subscribers/21631/9 "2019-07-26T14:13:15Z")

</div>

Closed on July 26, 2019, 2:13pm UTC

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