# PubSub: ERR\_BADAUTH even if scope is ok

**URL:** <https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972>\
**Category:** API\
**Created:** [November 8, 2020, 9:32pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972 "2020-11-08T21:32:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toniob](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/toniob/32/10648_2.png) [@Toniob](https://staging-discuss.dev.twitch.com/u/Toniob)\
**Post date:** [November 8, 2020, 9:32pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/1 "2020-11-08T21:32:58Z")

</div>

Hi,

I’m trying to listen to the _channel-points-channel-v1_ topic using pubsub. In the scope when generating my token, I’ve put _channel:read:redemptions_ as stated in the documentation : [https://dev.twitch.tv/docs/pubsub#topics](https://dev.twitch.tv/docs/pubsub#topics) .

But when i send the LISTEN message, the answer comes back with the error ERR\_BADAUTH.

If I add “channel\_read” in the scope, it works without the error. But this scope is deprecated from what I understand, and I don’t want those privileges, which I shouldn’t need.

Am I doing something wrong or am I missing something ? Or is it a bug in the API ?

Thanks

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 8, 2020, 9:35pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/2 "2020-11-08T21:35:42Z")

</div>

Did you use a user access token or a app access token?

The pubsub topics require a user access token.

> **[Getting OAuth Access Tokens](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/)**
>
> Getting OAuth Access Tokens

`response_type=code`

This suggests you got an app access token in error. You need a token that represents the user/broadcast you wish to get events for

---

<div class="post-metadata">

**Author:** ![Toniob](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/toniob/32/10648_2.png) [@Toniob](https://staging-discuss.dev.twitch.com/u/Toniob)\
**Post date:** [November 8, 2020, 10:01pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/3 "2020-11-08T22:01:21Z")

</div>

Thanks for the fast answer.

The token is a user access one, generated via the Implicit code flow. If I try a request to [https://id.twitch.tv/oauth2/validate](https://id.twitch.tv/oauth2/validate) with the header _Authorization: Bearer_ and the token, I’ve got a json response, with a _login_ key and a value which is my username.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 8, 2020, 10:02pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/4 "2020-11-08T22:02:11Z")

</div>

That would suggest you got a user access token for a different channel ID to the one you are trying to listen to

---

<div class="post-metadata">

**Author:** ![Toniob](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/toniob/32/10648_2.png) [@Toniob](https://staging-discuss.dev.twitch.com/u/Toniob)\
**Post date:** [November 9, 2020, 9:00am UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/5 "2020-11-09T09:00:27Z")

</div>

I’m using the endpoint : [https://api.twitch.tv/kraken/channel](https://api.twitch.tv/kraken/channel) to find the channel id. So it’s the right one. And if I only keep the _following_ topic, I don’t have the error, and if I try a follow on my channel, I’ve got the message through pubsub which confirm it’s the right one.

Any idea ?

Is there another to find my channel id ? I’m using v5 api for that, which is deprecated. Maybe there’s something new ?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 9, 2020, 12:32pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/6 "2020-11-09T12:32:23Z")

</div>

> [@Toniob](#):
>
> And if I only keep the _following_ topic, I don’t have the error, and if I try a follow on my channel, I’ve got the message through pubsub which confirm it’s the right one.

PubSub doesn’t have a following/follows topic.

> [@Toniob](#):
>
> Is there another to find my channel id ? I’m using v5 api for that, which is deprecated. Maybe there’s something new ?

User/Channel ID’s the same regardless of white API version you use.

> [@Toniob](#):
>
> If I add “channel\_read” in the scope, it works without the error. But this scope is deprecated from what I understand, and I don’t want those privileges, which I shouldn’t need.

So to confirm it is working with the “old scope” on the channel points topic but not the scope defined in the documentation?

Which doesn’t make sense since channel points is post Helix existing.

Edit: I tested I cannot replicate an issue. I generated a brand new access token for myself using the `channel:read:redemptions` scope and it booted right up.

 ![image](https://d2spem0quai2ol.cloudfront.net/original/2X/c/cbf79e504a44abd7af18f7a072f5f8d4d6b7fe89.png)

So we need to check your code next

I used [https://github.com/BarryCarlyon/twitch\_misc/tree/master/pubsub](https://github.com/BarryCarlyon/twitch_misc/tree/master/pubsub) to my pubsub and [https://github.com/BarryCarlyon/twitch\_misc/tree/master/authentication/implicit\_auth](https://github.com/BarryCarlyon/twitch_misc/tree/master/authentication/implicit_auth) to generate a token (modified the authorize URL)

Token validations

 ![image](https://d2spem0quai2ol.cloudfront.net/original/2X/1/10440ddc708d8dd5c6fa92322f78598a891cfab1.png)

---

<div class="post-metadata">

**Author:** ![Toniob](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/toniob/32/10648_2.png) [@Toniob](https://staging-discuss.dev.twitch.com/u/Toniob)\
**Post date:** [November 9, 2020, 3:41pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/7 "2020-11-09T15:41:10Z")

</div>

> [@"BarryCarlyon](#):
>
> PubSub doesn’t have a following/follows topic.

It seems it does. Try adding it and you’ll see you receive messages with the topic following._channelid_ .

> [@"BarryCarlyon](#):
>
> I used [https://github.com/BarryCarlyon/twitch\_misc/tree/master/pubsub](https://github.com/BarryCarlyon/twitch_misc/tree/master/pubsub) to my pubsub and [https://github.com/BarryCarlyon/twitch\_misc/tree/master/authentication/implicit\_auth](https://github.com/BarryCarlyon/twitch_misc/tree/master/authentication/implicit_auth) to generate a token (modified the authorize URL)

I checked the code you gave here. Thanks a lot. And I replaced my v5 _/channel_ api call with the helix _/users_ one, and now it works without the old scope _channel\_read_.

It seems ok now. Thanks a lot.

But can you check for the _following_ topic please ?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 9, 2020, 3:43pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/8 "2020-11-09T15:43:21Z")

</div>

> [@Toniob](#):
>
> It seems it does. Try adding it and you’ll see you receive messages with the topic following._channelid_ .
> 
> But can you check for the _following_ topic please ?

It’s not in the documentation.

> **[PubSub](https://dev.twitch.tv/docs/pubsub/)**
>
> PubSub Guide

Therefore it is not supported for use by third party developers, and as such it can change or break at any time.

There is no officially supported topic for follows.

> [@Toniob](#):
>
> I checked the code you gave here. Thanks a lot. And I replaced my v5 _/channel_ api call with the helix _/users_ one, and now it works without the old scope _channel\_read_.

Helix/kraken makes no difference, when trying to listen to pubsub.

Both kraken/helix will return the same UserID/channelID.

So this shouldn’t make a difference when trying to listen on the channel points Topic. So I’m still unsure as to why you are having a issue.

Since I didn’t call helix or kraken at all in my calls

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [December 9, 2020, 3:43pm UTC](https://staging-discuss.dev.twitch.com/t/pubsub-err-badauth-even-if-scope-is-ok/28972/9 "2020-12-09T15:43:24Z")

</div>

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