# OAuth not working

**URL:** <https://discuss.dev.twitch.com/t/oauth-not-working/19816>\
**Category:** API\
**Created:** [January 31, 2019, 8:47pm UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816 "2019-01-31T20:47:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![riki95](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/riki95/32/5744_2.png) [@riki95](https://discuss.dev.twitch.com/u/riki95)\
**Post date:** [January 31, 2019, 8:47pm UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/1 "2019-01-31T20:47:29Z")

</div>

Hi guys,  
hope this is the right section.

I want to develop a simple script that is able to cycle on a certain number of channels that I select (for example I gave to him a list) and I want him to give me back the follower’s number. So if I give him a,b,c,d he give me back  
a followers: 15000  
b followers: 20000  
…

I have created the application on the dev console and get my client ID.  
I am using a python library which is called python-twitch-client to interact with twitch and for some functions I need to generate an OAuth token.

How can I generate it?  
Because I tried with this [https://twitchapps.com/tokengen/#](https://twitchapps.com/tokengen/#) but after clicking continue, it brings me to localhost since I have set [http://localhost](http://localhost) in the OAUth redirect.  
Is this correct?  
So how do I get my OAuth so that I can continue?

Thanks guys

---

<div class="post-metadata">

**Author:** ![Dkamps18](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dkamps18/32/11559_2.png) [@Dkamps18](https://discuss.dev.twitch.com/u/Dkamps18)\
**Post date:** [January 31, 2019, 10:51pm UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/2 "2019-01-31T22:51:52Z")

</div>

No,  
The site your using sets the redirect\_uri to [https://twitchapps.com/tokengen/](https://twitchapps.com/tokengen/) and not [http://localhost](http://localhost)  
That will cause a ‘Parameter redirect\_uri does not match registered URI’ error  
Update the redirect\_uri parameter in the url and after Authorization page you will be redirected to [http://localhost](http://localhost) and find the access token in the url bar

---

<div class="post-metadata">

**Author:** ![riki95](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/riki95/32/5744_2.png) [@riki95](https://discuss.dev.twitch.com/u/riki95)\
**Post date:** [January 31, 2019, 11:08pm UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/3 "2019-01-31T23:08:19Z")

</div>

Thanks, that’s clear!  
I cannot modify that parameter on the website.  
But I can on my app on TwitchDev account.

So, I modified localhost with: `https://twitchapps.com/tokengen/`  
Because the website redirects here.

I authorize and what I get is:  
{“status”:401,“message”:“invalid csrf token”}

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Dkamps18](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dkamps18/32/11559_2.png) [@Dkamps18](https://discuss.dev.twitch.com/u/Dkamps18)\
**Post date:** [January 31, 2019, 11:18pm UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/4 "2019-01-31T23:18:58Z")

</div>

its working perfectly fine for me.  
you might as well follow [this page](https://github.com/Dkamps18/PHP-Twitch-lib/wiki/Getting-Started) start at “To get a access-token”, skip the steps you’ve already done and the last step

---

<div class="post-metadata">

**Author:** ![riki95](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/riki95/32/5744_2.png) [@riki95](https://discuss.dev.twitch.com/u/riki95)\
**Post date:** [January 31, 2019, 11:36pm UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/5 "2019-01-31T23:36:14Z")

</div>

Well,  
I do the following:

Paste this url to browser

```auto
https://id.twitch.tv/oauth2/authorize?client_id=YOUR-CLIENT-ID&redirect_uri=http://localhost&response_type=code&scope=SCOPES

```

I remove YOUR-CLIENT-ID and insert mine  
I remove SCOPES and live it blank

I press ENTER, i authenticate and then I get:  
**{“status”:401,“message”:“invalid csrf token”}**

Also if I insert something like **user:edit** instead of SCOPES, I get the same error.

Any suggestion?

---

<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:** [February 1, 2019, 12:59am UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/6 "2019-02-01T00:59:32Z")

</div>

You don’t need an oAuth’ed scoped key for what you have described as wanting to do. Follow counts are public information

A ClientID will suffice.

> [@riki95](#):
>
> {“status”:401,“message”:“invalid csrf token”}

This is a temporary issue and means you browser session is borked up usually.

---

<div class="post-metadata">

**Author:** ![riki95](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/riki95/32/5744_2.png) [@riki95](https://discuss.dev.twitch.com/u/riki95)\
**Post date:** [February 1, 2019, 7:37pm UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/7 "2019-02-01T19:37:36Z")

</div>

Hi Barry,  
thanks for the answer.

It seems very strange to mee, I tried from Chrome on Windows and it does this, but also from Chrome on Mac and from Safari on Mac.  
Are you sure is it a browser issue?

By the way is not clear to me how to get the follower count for a channel. Any suggestion?

---

<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:** [February 1, 2019, 7:52pm UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/8 "2019-02-01T19:52:15Z")

</div>

> [@riki95](#):
>
> Are you sure is it a browser issue?

Yes

> [@riki95](#):
>
> By the way is not clear to me how to get the follower count for a channel. Any suggestion?

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

---

<div class="post-metadata">

**Author:** ![riki95](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/riki95/32/5744_2.png) [@riki95](https://discuss.dev.twitch.com/u/riki95)\
**Post date:** [February 2, 2019, 10:04am UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/9 "2019-02-02T10:04:44Z")

</div>

Solved it, thanks!

---

<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:** [March 4, 2019, 10:04am UTC](https://discuss.dev.twitch.com/t/oauth-not-working/19816/10 "2019-03-04T10:04:46Z")

</div>

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