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(){
Twitch.ext.onAuthorized(function(auth){
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;
xhr.open("GET", "https://api.twitch.tv/helix/users?id="+userId,false);
xhr.setRequestHeader('client-id',clientId);
xhr.setRequestHeader('Authorization','Extension '+helixToken);
xhr.send();
if(request.status === 200){
username=xhr.responseText.data.display_name;
}
});
});
Am I on the right path here?