Hello, sorry guys I am new to the whole oauth thing. Can you point me to the right direction, I want user to be redirected to the same page after authenticating through twitch. Also I will list steps how I do it and maybe you can tell me if I am doing something wrong.
I am using node js on server side.
After clicking ‘log in’ button I redirect the user to the twitch login page with all the queries using document.location.href (not sure if that’s the right way to redirect)
Then after they granted the access to me the will be redirected to my URI which is blahblah.com/auth/login, on the server I do GET request to get access token. And then I have a problem, I need to redirect the person the initial page, but I don’t know the page link. where do i get this information? should i put the page into twitch oauth state, and then read it in server?
I would recommend to use Passport or Satellizer (for AngularJS) for your authentication. If you decide to use Passport, you can use passport-twitch, it’s an unofficial Twitch strategy for Passport that I created a few years ago. I never tried Satellizer to be honest, but I heard really good things about it if you are using AngularJS.
Another way to store the target URL besides flash storage and session cookies is to encode it in a JWT and send the JWT as OAuth2’s state parameter. The main advantage is that you don’t need any additional server storage until the user is actually authenticated and you can painlessly add more data if you need to.