Use oauth from different pages

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).