Javascript Auth blocked by CORS

Hi! I’m developping an app with require an Twitch authentication because I want the username of the user. When I do

xmlhttp.open(“GET”, “https://id.twitch.tv/oauth2/authorize?client_id=xxxxxx&redirect_uri=https://localhost&response_type=token”);

My request is blocked by CORS policy. I’m I missing something?

Thanks!

Hello, as far as i can tell you its not allowed to perform the request by a user(client side) you need a server that redirects the user to the Auth Window. See https://dev.twitch.tv/docs/authentication.

Cors is blocking it, cause twitch servers doesnt allow direct communication from browsers by using this Auth Flow

Step 1 of user oAuth his to REDIRECT the user to Twitch. Don’t fetch it yourself.

has an example of Implict auth, which is what token is for.

Na step 1 is redirect to Twitch, OP tried to fetch it instead of redirecting the user

Wow guys! Thanks you for answering that fast!! I’ll check your code in Github and try to implement it. :smiley:

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