# What do I do for OAuth redirect URL when registering a chat bot?

**URL:** <https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817>\
**Category:** Chat and IRC\
**Created:** [February 13, 2022, 4:40pm UTC](https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817 "2022-02-13T16:40:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hikiya4764](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@hikiya4764](https://discuss.dev.twitch.com/u/hikiya4764)\
**Post date:** [February 13, 2022, 4:40pm UTC](https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817/1 "2022-02-13T16:40:57Z")

</div>

I figure I probably need something for OAuth so that the program can log into my bot’s account, but I’m very very new to how OAuth works and am having a hard time understanding things like OAuth redirect URLs, and whether I even need one or if I can just make it localhost if this bot account’s the only thing it’s going to log into.  
Thanks all.

---

<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 13, 2022, 4:43pm UTC](https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817/2 "2022-02-13T16:43:29Z")

</div>

The oAuth redirect URL will be the sever/page/script URL that process the Step 2/3 of regular user oAuth

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

The code that exchanges the `?code` for an access and refresh token.

You’ll need to get a new token for your account every now and again (and the first time) if the key is invalidated for some reason. So having an easy way to give the bot new credentials is a good idea.

Sure localhost works but then that means the key exchange stuff lives on your computer and if you need to give the bot new keys whilst not at home, you are stuck with a non working bot!

---

<div class="post-metadata">

**Author:** ![hikiya4764](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@hikiya4764](https://discuss.dev.twitch.com/u/hikiya4764)\
**Post date:** [February 13, 2022, 5:19pm UTC](https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817/3 "2022-02-13T17:19:21Z")

</div>

Sorry, I’m like, really really new to all of this, but how do I get my account to authorize the bot? For the time being I think I’ll just use localhost and figure something else out down the road since this is more just a learning project than an actual bot I plan to regularly use.

---

<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 13, 2022, 5:23pm UTC](https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817/4 "2022-02-13T17:23:57Z")

</div>

> [@hikiya4764](#):
>
> how do I get my account to authorize the bot?

A bot account is _just_ a regular Twitch account.

So register a second Twitch account.

---

<div class="post-metadata">

**Author:** ![hikiya4764](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@hikiya4764](https://discuss.dev.twitch.com/u/hikiya4764)\
**Post date:** [February 13, 2022, 6:08pm UTC](https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817/5 "2022-02-13T18:08:08Z")

</div>

I’m really sorry, I probably am asking dumb questions, but what I’m asking is, how do I make this second account authorize it? From my understanding I go to the redirect URL or something, so for example if I wanted to make localhost that redirect, how do I set up localhost such that I can authorize the bot from there? Is there a good video or guide or something out there that’ll go into setting that stuff up?

---

<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 13, 2022, 6:46pm UTC](https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817/6 "2022-02-13T18:46:06Z")

</div>

You create a website  
You send the user to the website  
The user clicks “sign in with Twitch”  
The user is sent to twitch  
The user checks they are logged into the right twitch account and accepts or declines the link  
The user comes back to your site with a `?code`  
Exchange the `?code` for an access token/refresh token

For example I could say “hey I need an access token from you please visit my website [Twitch Implicit Auth Example](https://barrycarlyon.github.io/twitch_misc/authentication/implicit_auth/) to provide this”

And away we go.

This is a link to the implicit oAuth flow. Which differs from the flow described above. But should illistrate what I mean by a “website” and the oAuth loop.

There is also a farily extension guide with some Twitch Specific stuff for oAuth here [Authenticating with the Twitch API](https://discuss.dev.twitch.com/t/authenticating-with-the-twitch-api/29237)

But this is just industry standard oAuth. Once you know how it works you can get tokens for a lot of different services jsut feed it different URL’s

---

<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 15, 2022, 6:46pm UTC](https://discuss.dev.twitch.com/t/what-do-i-do-for-oauth-redirect-url-when-registering-a-chat-bot/36817/7 "2022-03-15T18:46:54Z")

</div>

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