Twitch.TV JS SDK not retaining session grant?

I am trying to set up an embedded “Follow” button on my website using the javascript SDK. All I want is to put a “Connect using Twitch” button below the video player. When someone clicks on the button, it will POPUP the authorization form from Twitch where they can confirm the grant. So far this is all working.

However, nothing else is actually working. According to the JS SDK page, the user’s authorization token should be stored in either their DOM or in a cookie. However, no matter what happens, my code is always reading the authenticated status as “false”. I tried both the popup method, and the non-popup method.

This is my code:

<script src=""></script>

	$(function() {
		Twitch.init({clientId: '**********'}, function(error, status)
			if (status.authenticated)

				scope: ['user_follows_edit', 'user_subscriptions'],
				redirect_uri: '',
				popup: true

<a class="twitch-connect twitch"><span>Connect with Twitch</span></a>

Here is a URL with the issue:
(the ?test=1 code is essential to see the Twitch JS SDK stuff; Twitch stuff shows up in purple, everything else is unrelated)

The registered URI is

I also have a second question would be, how to trigger a piece of code to happen when the user finally authorizes and it works. Normally, you wouldn’t need to trigger the code; but in this case, I want to use the “popup” feature, since the page is not the redirect uri.

Okay… I’ve figured out the issue… BOTH URLs have to have the JS SDK initiliazed on it.

I did not have the JS SDK on

However, I am experiencing another issue. Once a user has been granted a session key, that session key seems to be only accessible in that specific instance of the browser. So if I am not using the popup: true option, it works perfectly fine.

But, if I am using popup: true, then the authorization grant is opened up using a function (as defined here: The session key stored for the authorization grant only works in that opened popup window; not the original window that opened the Twitch.login() function in the first place. If this can’t be done, then this seems like a massive oversight on the JS SDK; which makes the popup: true option completely worthless.

How do I get the session key back to that original window? As well, how do I trigger an event on that original window after a user has logged in and authorized the application?

One more question… how can I have the authorization keys stored in Local Storage, instead of Session Storage?