Issue with pubsub authentication

Hi all,

I’ve been working on a custom layout for twitch, and wanted to use PubSub for getting bits and subscriber notifications. I was using socket.io for the connection but didn’t seem to connect at all, so I switched to the native WebSocket library. I was able to connect with that, but am getting a ‘ERR_BADAUTH’ when trying to subscribe to the subscriber topic. I know the token I’m passing is good since I’m using the same for my website, and I am omitting the ‘oauth:’ portion too.

twitchSocket.onopen = (event) => {
      console.info('socket connected!');
      intervalId = setInterval(this.socketHeartbeat, 2 * 60 * 1000);

      twitchSocket.send(JSON.stringify({
        type: 'LISTEN',
        data: {
          topics: ['channel-subscribe-events-v1.MyUserID', 'channel-bits-events-v1.MyUserID'],
          auth_token: 'abc123', // changed for security
        },
      }) );
    };

That’s my connect code if it helps. I was able to connect fine without the subscriber event as well.

Are you sure your token has the channel_subscriptions scope which is required for the channel-subscribe-events topic?

As per the docs

You need to make sure that the auth key you are using has any scope for the bit’s topic, and a key with channel_subscriptions scope on it as @milo says

ERR_BADAUTH means your key is invalid for one or more topics your requests to listen on in the same listen send.

I did add the channel_subscriptions scope, and remember the oauth saying it too. It shouldn’t matter if I also have channel_editor scope on the token right?

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