Get Channel ID where the extension is currently displayed

Hi everyone,

how do I get the name (or preferably the ID) of the channel that my extension is embedded in?

At the moment I do the following:

  window.Twitch.ext.onAuthorized((auth) => {
    log('Live on channel', auth.channelId);
    window.TwitchChannelId = auth.channelId;
    main();
  });

However, I’m not confident that this will work for non-logged-in users. Is this the recommended way, or is there a better way?

Thank you for your help!

Not sure it works? Test it!

ChannelID is always returned in the auth callback

Thank you, I have tested it.

Does this also work for non-logged-in users? I have no way to test that before the extension is approved.

Good point. Hand’t had coffee yet :stuck_out_tongue:

You can test a logged out view with the developer rig

https://github.com/twitchdev/developer-rig

The only difference between logged out, logged in not authed, logged in auth, is if a UserID is returned and what kind of opaqueID you get.

The channelID is always returned.

1 Like

Thanks you for your help!

I don’t have the dev-rig set up for the extension I’m developing, as I’m integrating heavily with the video on stream, so I didn’t even know that was a feature.