Understanding where Channel ID comes from

Hi,

I am playing around with the sample Hello-World app and trying to understand where the channelId comes from. I cant find very good documentation on the twitch API or the data objects which are there.

Is there someone that explain the basic ‘flow’ of an extension when its loaded into a streamers page and the basic objects that exist in the twitch API?

There isn’t really a basic flow, each extension does something different depending on what the Extension is and how it works and what it does.

All extensions will usually wait for onAuthorised and then from there it’s a mixture.
Some people will punt the JWT straight offsite to the EBS, others won’t bother and locally parse the JWT for the channelID and other data.

You can easily get the channel ID as documented here however:

onAuthorized

twitch.ext.onAuthorized: function(authCallback: Function)

This callback is fired each time the JWT is refreshed.

authCallback is a function with one argument, an object with these properties:

Property Type Description
channelId string Channel ID of the page where the extension is iframe embedded.
clientId string Client ID of the extension.
token JWT JWT that should be passed to any EBS call for authentication.
userId string Opaque user ID.

For example:

window.Twitch.ext.onAuthorized(function(auth) {
  console.log('The JWT that will be passed to the EBS is', auth.token);
  console.log('The channel ID is', auth.channelId);
});

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.