Use oauth from different pages

Seems like if I authorize from www.example.com it works, but I get redirect_mismatch error if I try to authorize from
www.example.com/sample the redirect-uri is www.example.com on both the website and my application. Is it possible to make Authorization available on every page of application?

If you get a redirect_mismatch the specified redirect_uri does not match the redirect URI registered for your application. Make sure it does. I think even the presence of a trailing / (or the lack thereof) matters; as it should.
AFAIK there is no other condition resulting in a redirect_mismatch, at least I never encountered one.
If the redirect_uri really does match, could you post the two URLs (with all sensitive data removed of course)?

You can only have one redirect landing page per client is. What most people do is have a landing page that will receive the token for the entire domain/application and then redirect back to whatever the original page was. You can use the state parameter for keeping track of this data.

I was using the JS SDK, and two links are identical, I just now copied one from Twitch and past it into application, so I want my application to go to one link after signing in, but it only works on www.example.com, if I put the same code with the same redirect_uri(www.example.com) on www.example.com/kappa, it wont redrect to www.example.com it just says redirect_mismatch. Maybe it is JS SDK and I shouldn’t use it?

Make sure you pass the redirect_uri explicitly to Twitch.login like this:

Twitch.login({
  redirect_uri: 'https://example.com/authorize',
  // popup, scope, ...
});

If you don’t, the SDK automatically uses the current URL as redirect_uri which will not work in your case.

All of this is described in the official documentation (scroll down to Twitch.login).

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