Twitch API in an extension

Hey Barry, can you help me validate if this is the correct method to obtaining the userID.

The information I got was from this guide: Using the Twitch API in an Extension Front End | Twitch Developers

I’m trying to do it in javascript on client-side since that would be the fastest way:

document.addEventListener("DOMContentLoaded", function(){
		size = {
		  width: window.innerWidth || document.body.clientWidth,
		  height: window.innerHeight || document.body.clientHeight
		var userId= auth.userId;        //Opaque User ID
		var Token=auth.token;       //Probably don't need this...
		var helixToken=auth.helixToken; //Oauth basically...
		var clientId=auth.clientId;"GET", ""+userId,false);
		xhr.setRequestHeader('Authorization','Extension '+helixToken);
		if(request.status === 200){;

Am I on the right path here?

You shouldn’t wrap it in document.addEventListener("DOMContentLoaded", function(){

But otherwise your code seems correct, other than you didn’t parse the result to JSON but I don’t use XHR

The user ID doesn’t need an API call, the userID is in - if the user has logged into the extension.

OH It’s a VARIABLE, here I was thinking it was some sort of library. Now I feel really dumb. Thank you!

I haven’t done much with JSON & Javascript, but you’re probably right about needing to parse it.