Popup window login flow using JavaScript SDK

I’m looking into this from the SDK perspective. That SDK hasn’t been updated or maintained in a while (3+ years), unfortunately, so this may be an unknown bug. The popup: false case works as expected but popup: true doesn’t.

Having said that, one thing you could do is store it in sessionStorage, which is what the SDK does. Something like this in setAuthToken:

  var SESSION_KEY = 'twitch_oauth_session';
  window.sessionStorage.setItem(SESSION_KEY, token);
  
  console.log(window.sessionStorage.getItem(SESSION_KEY));

You can use the Storage.getItem function (as shown above) to reference the key for API calls or into a persistent store. This should work for all recent browsers (IE8+).