Hi , I am creating a a Discord Bot thats display in a message the number of subs of the channel.
Im trying to get the OAuth authorization code flow token for making a request to get the subs but I dont know how to make it.
I made a GET request (to https://id.twitch.tv/oauth2/authorize) and I get an url , I paste it in google and it goes to a page to autorize the twitch app (all sounds good at this point) but then nothing happens.
It gets me to localhost.
When registrating my app I put http://localhost as the URL and I think thats the error but I dont know.
I have read the documentation a LOT of times but I didnt got a lot of it.
The bot its just for one channel (if this information is important)
To obtain a token to access Twitch prividged data.
You need to create a webpage.
That webpage will display a <a href="" that starts https://id.twitch.tv/oauth2/authorize
user clicks that link
user accepts of denies the link
if they accept they come back to your return URL with a ?code= you exchange that ?code= for an access token and refresh token via a HTTP POST request.
You store the user access token and refresh tokens
Use the user access token till it expires, then make a new token using the refresh token.
You may get a new refresh token when doing so.
If the refresh token doesn’t work then you’ll need the use you want to read subs for to do this flow all over again.
So,
If you left it as localhost then sounds like you are authing yourself, then you just need a webserver at that URL to do the auth process.
The above is for “regular” oAuth
You can instead use implict but then every 60 days you have to do the manual steps all over again. (Also generally thats what the third party third party token gens use which makes it annoying to seed it with a new token perodically.
Here are two example projects
One in node and one in PHP that demonstrate this flow. You would need to modify it to store the token/refresh token whever you need to for the discord bot to access it
Here is a link to the documentation, and two examples in two different langages.
This forum is the forum, and we can answer questions like we already have been doing.
For the TwitchDev Disorc there is this Intro Video about oAuth that might help
Ok I dont know how I made a simple webpage, but I dont know what have to be the structure of the page.
I mean I have a button that runs the script that you put on git, I suposed that I have to add my web url to the app in the registrarion page in twitch.
The main question is like ok I ahve the URL that the twitch server provides with the requests , and my web page mid finish, how do I make the interaction betewn them