Login/Auth & Redirect URI Help

My buddy and I would like to be able to incorportate
the twitch login button by using the Twitch API, but have recently hit a road block.
We have purchased a domain and hosting and are currently hung up on setting up the redirect URI
along with getting the redirect link to send users to Twitch.tv to get the initial authorizaiton
& being able to redirect them back to our site upon login. Our site is currently written in HTML5 with light js
Any help would be greatly appreciated!

You create a page with a button to connect to Twitch from. You create a page that you use as the redirect_uri that Twitch calls back and pushes data to. Are you asking for source code on how to scrape the data back from Twitch and to send people to Twitch?

So I currently have this login box
.Twitch login box

But I need help routing the users to This screen when they sign in

and finally I would like them to link back to my site after they log in with twitch

That middle screen almost looks like the Twitch page that informs you as to which permissions the application wants. Twitch handles that itself. Then, from there, Twitch pushes the user to your redirect_uri which you give Twitch with your application and Twitch will automatically reroute to when you provide that in the authorize endpoint:


Did you register an Application with Twitch to get your Client ID and Secret ID and register your redirect_uri?

Ah I think I may have had the wrong syntax when I was trying to key in my URI redirect. I have registered and also replaced areas with the client id as needed but I keep receiving either one of the two following errors;

{“error”:“Bad Request”,“status”:400,“message”:“Missing param: client_id”}
{“error”:“Not Found”,“status”:404,“message”:null}

Would I need to create a separate page specifically for redirects?

The first issue looks like you are not passing the client_id when authenticating with Twitch. The not found 404 could very well be that it cannot find the redirect, but not entirely sure. I usually use separate pages for redirects when capturing data for authentication, but I admit I use mine more for capturing tokens than using as a login service. However, the overall usage should be the same, if there is an authentication that occurs, Twitch will send the user automatically to the redirect_uri which you can use as your landing page and then redirect them to the protected area of your site.

I am not sure if this would help you, but a JS SDK is provided by Twitch, unless this is what you are trying to use already:

that actually is the SDK I have been attempting to use.Do you happen to have any resources that you would recommend for storing the tokens and creating that secure area?

There shouldn’t be a need to store the keys back from Twitch, the SDK handles all of that internally, you just check to see if the user authenticated or not before presenting data if you are trying to limit it by user. As the SDK says, it handles the authentication and tracking of that for you. More than likely, as I haven’t used this SDK, it just stores the tokens in memory.

okay. thank you so much for your help! One more question, in regard to the connect with twitch button; would i replace the link within the href attribute with the one you posted above, or would I use the redirect URI for that address?

The Connect to Twitch button goes to Twitch:

Then, Twitch, after they authenticate the user for you, automagically push the user to REDIRECT_URI. Whatever that may be (http://nowhere.com/twitch_landing.html – whatever).


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