Understanding where Channel ID comes from

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);
});