PubSub twitch.listen can't authenticate properly on broadcast channel

Hello, I am just getting familiar with the extension environment, but I ran into an issue regarding the client-sided listen function for the PubSub.

When I subscribe (listen) to the broadcast channel from the client-side I get an ERR_BADAUTH response from the SOCKET. At first I suspected this was because the extension had to finish authenticating before subscribing, so I put it on a 5 second timeout before starting to listen. But as soon as it starts it sends this over the socket:
So the BADAUTH error persisted. I verified and decoded the JWT from the same client in my EBS and there seemed nothing wrong:
{ exp: 1617196882, opaque_user_id: '<opaqueID>', role: 'viewer', pubsub_perms: { listen: [ 'broadcast', 'global' ] }, channel_id: '<channelID>', user_id: '<userID>', iat: 1617110482 }

So it definitely has the necessary listen permissions (that being broadcast), but it still does not work!

Keep in mind, this is all even before I even send my first message from the EBS, the issue lies in authenticating to the socket.

The code I use to listen:

setTimeout(() => {

  twitch.listen('broadcast', function(topic, contentType, message) {
    twitch.rig.log("listen() fired, received PubSub message: " + message)

}, 5000);

Where the timeout of course is temporary and just there to make sure this fires AFTER authentication.

Are you testing in the Developer Rig or the Twitch Website?

I am using the twitch rig, popped out to the browser.

That would suggest that the Rig has incorrect settings/config for your extension.

Try the “refresh manifest” button and then recreate any views

Refreshed manifest, but issue persists.

Something else worth adding is that I am getting CORS errors:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (Reason: CORS request did not succeed).

Two of these every few seconds.

They are regarding these requests.

Somebody in the support discord told me this was unrelated, but I am starting to doubt that!

Did you recreate the view?

Yes that was me.

Pubster is, if I recal correctly, a stats system. So expected to fail for in dev extensions/dev rig tested extensions

I did recreate the view yes.

Next step is to toally destory the extension in the rig. Use “Close Project”

Then recreate the project in the rig from scratch (using the existing extension)

Also check you are running the latest version of the Rig, which should be v1.2.14

That was it!
When remaking the project the issue suddenly fixed itself. No clue why!

Thank you very much!

EDIT: Would this be bug-report viable?

One of more of the settings were borked and manfiest refresh fixes most not all. So a nail and remake away you go


1 Like