# Streams followed api returning 401 unauthorised

**URL:** <https://discuss.dev.twitch.com/t/streams-followed-api-returning-401-unauthorised/24757>\
**Category:** API\
**Created:** [April 2, 2020, 10:29pm UTC](https://discuss.dev.twitch.com/t/streams-followed-api-returning-401-unauthorised/24757 "2020-04-02T22:29:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ragnaroksb](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@ragnaroksb](https://discuss.dev.twitch.com/u/ragnaroksb)\
**Post date:** [April 2, 2020, 10:29pm UTC](https://discuss.dev.twitch.com/t/streams-followed-api-returning-401-unauthorised/24757/1 "2020-04-02T22:29:14Z")

</div>

Hey guys,  
I am new to twitch.

So far, I have done these steps

- Created account with twitch

- Added 2 Factor auth

- Created an application and obtained the clientId

- I am getting the access token as per the document below

- Then I am getting the live streams as follows

- I am trying to get the Followed streams as per the api below

- I keep on getting the error below for the followed streams api

- The API to get accesstoken is as follows  
curl --location --request POST ‘[https://id.twitch.tv/oauth2/token?client\_id={my\_client\_id}&client\_secret={my\_client\_secret}&grant\_type=client\_credentials&scope=user\_read](https://id.twitch.tv/oauth2/token?client_id=%7Bmy_client_id%7D&client_secret=%7Bmy_client_secret%7D&grant_type=client_credentials&scope=user_read)’

- I then use the accessToken in the api below

I keep on getting

{  
“error”: “Unauthorized”,  
“status”: 401,  
“message”: “authentication failed”  
}

Any suggestions on what I am doing wrong?

---

<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:** [April 2, 2020, 10:33pm UTC](https://discuss.dev.twitch.com/t/streams-followed-api-returning-401-unauthorised/24757/2 "2020-04-02T22:33:10Z")

</div>

> [@ragnaroksb](#):
>
> The API to get accesstoken is as follows  
> curl --location --request POST ‘[https://id.twitch.tv/oauth2/token?client\_id={my\_client\_id}&client\_secret={my\_client\_secret}&grant\_type=client\_credentials&scope=user\_read](https://id.twitch.tv/oauth2/token?client_id=%7Bmy_client_id%7D&client_secret=%7Bmy_client_secret%7D&grant_type=client_credentials&scope=user_read)’

The scope here is useless. As `client_credentials` doesn’t represent user, so there is no `user` to read

So that is your problem. You tried to get the streams that a user follows, but your access token doesn’t have a user

> [@ragnaroksb](#):
>
> –header ‘Authorization: Bearer {accessToken}’

Also for kraken it’s `OAuth` not `Bearer`

> **[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.

---

<div class="post-metadata">

**Author:** ![ragnaroksb](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@ragnaroksb](https://discuss.dev.twitch.com/u/ragnaroksb)\
**Post date:** [April 2, 2020, 10:46pm UTC](https://discuss.dev.twitch.com/t/streams-followed-api-returning-401-unauthorised/24757/3 "2020-04-02T22:46:25Z")

</div>

thanks BarryCarlyon for your quick reply.

I tried it again  
curl --location --request POST ‘[https://id.twitch.tv/oauth2/token?client\_id={my\_id}&client\_secret={my\_secret}&grant\_type=client\_credentials](https://id.twitch.tv/oauth2/token?client_id=%7Bmy_id%7D&client_secret=%7Bmy_secret%7D&grant_type=client_credentials)’

And followed api as below  
curl --location --request GET ‘[https://api.twitch.tv/kraken/streams/followed](https://api.twitch.tv/kraken/streams/followed)’   
–header ‘Accept: application/vnd.twitchtv.v5+json’   
–header ‘Client-ID: {myId}’   
–header ‘Authorization: OAuth {myToken}’

I get the error  
{  
“error”: “Unauthorized”,  
“status”: 401,  
“message”: “invalid oauth token”  
}

---

<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:** [April 2, 2020, 10:48pm UTC](https://discuss.dev.twitch.com/t/streams-followed-api-returning-401-unauthorised/24757/4 "2020-04-02T22:48:04Z")

</div>

> [@BarryCarlyon](#):
>
> So that is your problem. You tried to get the streams that a user follows, but your access token doesn’t have a user

You need to use a flow that grants a `User Access Token` as per the table on [Authentication | Twitch Developers](https://dev.twitch.tv/docs/authentication#getting-tokens)

| Procedure | User Access Token | ID Token | App Access Token |
| --- | --- | --- | --- |
| [OIDC Implicit Code Flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oidc/#oidc-implicit-code-flow) | ✔ | ✔ | |
| [OAuth Implicit Code Flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-implicit-code-flow) | ✔ | | |
| [OIDC Authorization Code Flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oidc/#oidc-authorization-code-flow) | ✔ | ✔ | |
| [OAuth Authorization Code Flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-authorization-code-flow) | ✔ | | |
| [OAuth Client Credentials Flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-client-credentials-flow) | | | ✔ |

usually:

> OAuth Authorization Code Flow

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

---

<div class="post-metadata">

**Author:** ![ragnaroksb](https://avatars.discourse-cdn.com/v4/letter/r/7c8e57/32.png) [@ragnaroksb](https://discuss.dev.twitch.com/u/ragnaroksb)\
**Post date:** [April 7, 2020, 10:07pm UTC](https://discuss.dev.twitch.com/t/streams-followed-api-returning-401-unauthorised/24757/5 "2020-04-07T22:07:43Z")

</div>

Thanks BarryCarlyon,

I was finally able to get it working. Thanks for your help.

Cheers

---

<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:** [May 7, 2020, 10:07pm UTC](https://discuss.dev.twitch.com/t/streams-followed-api-returning-401-unauthorised/24757/6 "2020-05-07T22:07:47Z")

</div>

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