OAuth Redirect URL

Hi I found a requirement on the Twitch App site to register an App you need an OAuth Redirect URL. I know what it is but how do I get one? Please, somebody, help me!
Update: I found a way to get the Redirect URL and now I have the token but what do I do with it? (For the OAuth Redirect URL put to do it put https://twitchapps.com/tokengen/ and there you should get the token)

1 Like

You and me both bother! I have scouring this for days yet no one seems to have a really straight forward answer. Maybe you can work better than me with the information I know.

I know I was told you can use http://localhost as your redirect url.

I was also told you can use this website for the implicit code flow method: https://twitchapps.com/tokengen/

I tried putting the local host as in my redirect for my app and I tried going to that link and clicking “connect to twitch” but then it brought me over to my IIS and it didn’t give me token! So I don’t know what to do.

I know Oauth is used elsewhere but I never had to do this to get the token. For discord, I just clicked on a link that copied my token for me and then I was on the next steps. Here I have no clue what to do.

I hope you have better luck than me!

The Redirect URL is whatever you want it to be. It’s where users will be redirect to when connecting to your app.

If you need to send users through the authentication process for your app, then you’ll need a URL that is publicly accessible and a webserver setup to handle the process. If you just need to authenticate yourself (or don’t need to use the Authentication process at all), just put in http://localhost as that will redirect you back to yourself.

I gave you the oAuth dance here

This website uses it’s own clientID and secret to create a token. You cannot use it, using YOUR clientID

As you must write the code to exchange the code for a token (when using OAuth Authorization Code Flow as documented

If using implict make sure you set the right data when passing to /authorize

Again Discord is giving you a bot login token for running a bot, it’s not really a oAuth token

oAuth for implicit is noted here

If you don’t plan to use oAuth in your App, set it to https://localhost as it should say on the ClientID creator page

while writing this, I was able to get my token! I will explain in my next post below…I hopefully I can add pictures??

I am leave my post below for Barry as I want him to know where I was coming from. I thank him so much man! (also sorry if it sounds rude. I am not trying to be or anything, its just some of it didn’t make sense so I wanted to elaborate. Not like it matters now as I think I have my token.

I don’t know how to qoute Barry so I am going to just copy and paste to answer him because I don’t think we are on the same page:

Barry, you said -
“This website uses it’s own clientID and secret to create a token. You cannot use it, using YOUR clientID”

That doesn’t make sense. The website: (Twitch OAuth Token Generator) says specifically to, " You will need to first register an application in your Twitch account settings to obtain a Client ID and enter the Redirect URL below.

Client IDScopes List of available scopesRedirect URL: https://twitchapps.com/tokengen/

This application uses the implicit grant flow for the Twitch API to retrieve your token. This means that your token is only ever visible to your browser and not our server."

So you saying, “This website uses it’s own clientID and secret to create a token. You cannot use it, using YOUR clientID” doesn’t make sense when it says, " You will need to first register an application in your Twitch account settings to obtain a Client ID and enter the Redirect URL below."

Does what I wrote explain why I am confused as to what you are saying regrading that?

Here is another thing you said, " As you must write the code to exchange the code for a token (when using OAuth Authorization Code Flow as documented"

I already did that man! Infact, that was the first thing I tried before someone from the Discord gave me the token link. Here is my exact code word for word in python

"import requests

params = (
(‘client_id’, ‘izbr3e0woto5nlw13belle04zsrtvf’),
(‘redirect_uri’, ‘http://localhost:3030’),
)

response = requests.get(‘https://id.twitch.tv/oauth2/authorize’, params=params)
"

The problem is I don’t get any reply back run it. It just runs, then goes to the next line without giving me anything. THAT IS WHY I tried the oauth token link which I thought would be used to give myself a token if I put in the localhost:3000 as my redirect link for my app.

Does that make sense? I tried writing code and I got no errors back for me to know where the issue is, so I went to try it graphically.

Now mind you, if I put in “requests.get(‘https://id.twitch.tv/oauth2/authorize?client_id=izbr3e0woto5nlw13belle04zsrtvf&redirect_uri=http://localhost:3000’)” It will give me a response of 200 which means it saw it my http request. However when I tried to write code to pull back my token (as you saw my python code above) nothing came out of my IDE 3.7. It just went to the next line and didn’t give me a response. Maybe the code itself is off?

Another thing I noticed you posted, “Again Discord is giving you a bot login token for running a bot, it’s not really a oAuth token”

I apologize as I must have missed you saying that first time because I don’t remember that. If that is the case, then its makes sense why this is hard; there has been no time before this that I ever needed Oauth and I am pretty sure the OP is the same. There should be a note under the redirect URL that says to put local host if you are making the app for just yourself. (Then again, that still wont help noobs like myself if they are using local host for there ftp server)

One other very important post you gave me is this," If you already have a webserver running on localhost, and haven’t set it up to handle the OAuth process, then yeah it likely wont work as you’re doing other stuff on that port, so use a different one, for example http://localhost:3000 1 and try again.

You should get redirected back to that URL with various querystring parameters in the URL depending on what auth flow you used, eg,
http://localhost:3000?code=394a8bc98028f39660e53025de824134fb46313&scope=viewing_activity_read&state=c3ab8aa609ea11e793ae92361f002671"

I tried port 3000 and it didn’t give me anything but I will explain a little better.

I tried putting http:localhost:3000 in my python code so it came out like, "
import requests

params = (
(‘client_id’, ‘izbr3e0woto5nlw13belle04zsrtvf’),
(‘redirect_uri’, ‘http://localhost:3000’),
)

response = requests.get(‘https://id.twitch.tv/oauth2/authorize’, params=params)
"

However that didn’t give me any reply back from IDE 3.7. It just went to another line like I mentioned above. I know my python works because as I mentioned earler the get request came back with a 200 rsponse so I know it works…I think my code is off maybe but it wont give me any errors for me to figure out where to go from there.

I also tried putting http://localhost:300 in the redirect URL on my app and tried using the token link Twitch OAuth Token Generator to try and give me a token (thinking it was going to give a token in the address link or something.) and nothing came up. while typing this I think I figure out my stupid issue. I will post it in a separate post so that the OP can know what I did.

That whole information above was for Barry. I wanted to make sure he knew I was trying and wasn’t just ignoring him. He is so freaking helpful even though I am a noob and am probably frustrating. Still he has been patient and still answers even though its redundant. Thank you

Before I start again I did read this:

Yeah, I understand where you are coming from but I felt I had to do that. I had to force myself to keep asking everywhere I could because this is that important to me. So much so that I was willing to pay someone to give me my token just so I can work pas this. I NEED a channel update script and I would have paid for one if it exists. The fact that there isn’t one on github I can just use means I need to step up my game and learn a bunch of stuff in programming that I don’t normally come across. I knew importing and modules already but I never used Oauth in anything before so I just kept getting stumped.

BarryCarlyon (awesome person) Kept trying to help but none of it makes sense and I just randomly stumbled upon my token as I am such the idiot.

Also (as a side note) I am going to post what I said on the Discord developer channel when someone told me to go back to the basics of programming::

"Learning recursion doesn’t help with oauth
learning programming doesn’t help with making a twitch program api, the two things are just different. Learning the basics of programming doesn’t show how to use any of the api for twitch or oauth. You have to learn those specific things. The only way I would have came across this is if I needed to use Oauth for another website and they didn’t give me a link. Like I mentioned a day or two ago, Discord had a link for the token which made this alot easier. Its not like I had to learn the ful basics of a programming language to get my discord chat bot up and running and that is point there.
I have already done every single lesson in code academy for python. Does that mean I am going to know APIs, or Oauth? No way! That is the point, I have to go in head first and not know shit, till it starts making sense. If it was easier, I don’t think I would have posted in here or on the twitch dev forums so much these last couple of days.

I have been working on my twitch for months and have been learning batch scripts for OBS and VLC, python scripts for my instagram , twitter and discord, and so far everything has been good for learning. Some stuff is fustrating but nothing a good google search and some determination can’t solve. (plus common sense and the will to learn).

However twitch has been kicking my ass super tuff. I am embarrassed to say that I have a network certification after dealing with this crud… lol!"

My quote above is the reason I kept bothering this forum. I can spends days learning about programming which I did daily anyway However, I have NEVER came across OAuth. Me understanding programming and me understanding Oauth are two different things. Its like, you can understand how to make a program without knowing Oauth at all and that shouldn’t stop me from making my script."

I will say this, if I do learn Oauth to a very good degree I am going to make a video tutorial that is very slow and graphical for ANYONE to atleast understand the concept of it so when they go back to there programming language of choice, they can just go from there. (atleast I hope I can teach that good. hahaha)

1 Like

Ok here is what I did to get my token. I assume this is for yourself only and not for if anyone wants to use your bot…I believe…I’m not super smart. lol

  1. Make your bot app from here: https://glass.twitch.tv/console/apps
    1b. Fill in the:
    Name - (anything you want)
    Category - (choose any category your bot applies to)
    OAuth Redirect URL - (put in this link: https://twitchapps.com/tokengen/)
    1c. Then click “save” and afterwards you should your client id on that webpage as well. (you are going to need it)

  2. Open a new tab and go to the link: https://twitchapps.com/tokengen/
    2b. Put your
    client ID - (the one that was generated after you saved your app settings)
    2c.(optional) You can put in scopes but I haven’t used it yet…the link on that page regarding scopes is busted but if you want to know more about scopes go here https://dev.twitch.tv/docs/authentication/#scopes (I should read more about it as well.)
    2d. Click “connect to twitch”.

  3. If done right, you will be brought to an authorization page asking you to authorize your bot to do stuff on your behalf (obviously allow this or why are you here? lol)

  4. Your token will be provided right after on the next page.

Man I am so stupid, the webpage wants you to put there redirect url in your app so it redirects there. OMG, i’m such an idiot.

I’m not going to tackle the huge wall of text you posted, but I noticed a couple things worth mentioning.

First off, you make a GET request to the the auth url and then say nothing happens… Well, what do you expect to happen, have you programmed it do actually do anything with what you just requested? Also from what I can see of your code you’re not even providing all of the required parameters, such as response_type. Read the docs to see what parameters you need to send.

Secondly, that’s not even how OAuth works. You can’t just do a GET request to the auth url as all that will happen is you’ll get back the HTML from Twitch. For user access tokens you need to actually send the user to that URL so they go to it in their browsers, they will then see a Twitch page asking them to authorise your app, and if the do the user’s browser page will be redirected back to your redirect URL.

A lot of your issues are coming from your lack of understanding certain concepts, such as OAuth, HTTP requests, and things like that. You would be far better off trying to gain an understanding in the various pieces that are involved in utilising the Twitch API, and how to make use of them in your programming language by looking for specific modules, their documentation and guides on their use, rather than trying to brute force something together that works with Twitch without actually understanding how any of it works as you wont learn anything.

3 Likes

Well theres your problem.

You tried to GET the twitch login page, instead of redirecting the user to the login page.

As covered here, in your original post where I also touched on Discord

Oh and thread closed as @Sir_Cheese_123 is now totally sidetracked by @masterjx9 please open a new thread if you see need help sir_cheese