Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad_auth #89

Open
Vlad0sZ opened this issue Jun 18, 2021 · 10 comments
Open

Bad_auth #89

Vlad0sZ opened this issue Jun 18, 2021 · 10 comments

Comments

@Vlad0sZ
Copy link

Vlad0sZ commented Jun 18, 2021

Hello, I am getting a bug on version 3.2.3-preview. But in 3.2.2 version is good.
image
image
It is example code from here https://github.com/JayJay1989/TwitchLib.Pubsub.Example

@Mahsaap
Copy link
Member

Mahsaap commented Jun 18, 2021

EDIT: I'm told this isn't the case, But ill leave the info here. I'm not sure what would be causing that atm.

_I asked in Discord about this, But the only difference I see between the versions is the ListenToBitsEvents method is now obsolete and now is ListenToBitsEventsV2.

`

[Obsolete("This topic is depreacted by Twitch. Please use ListenToBitsEventsV2()", false)]
public void ListenToBitsEvents(string channelTwitchId)

`

If you are using that old method please try the new one and if this is the cause, I will PR request the old one to be removed._

@swiftyspiffy
Copy link
Member

Looking

@swiftyspiffy
Copy link
Member

So using the obsolete (v1) ListenToBits, I'm getting:

Connecting!
Connected!
[LOG] {"type":"RESPONSE","error":"","nonce":"D5Wg1E
Y4"}

[ListenResponse] #44338537: True
[LOG] {"type":"MESSAGE","data":{"topic":"channel-bi
ts-events-v1.44338537","message":"{\"data\":{\"user
_name\":\"swiftyspiffy\",\"channel_name\":\"burkebl
ack\",\"user_id\":\"40876073\",\"channel_id\":\"443
38537\",\"time\":\"2021-06-19T00:40:35.670813582Z\"
,\"chat_message\":\"Cheer1 this is a test\",\"bits_
used\":1,\"total_bits_used\":47480,\"context\":\"ch
eer\",\"badge_entitlement\":null,\"badge_tier_entit
lement\":{\"Badge\":{\"new_version\":0,\"previous_v
ersion\":0},\"Emoticons\":null}},\"version\":\"1.0\
",\"message_type\":\"bits_event\",\"message_id\":\"
063b40c4-59ab-5c68-bce8-8523c28de635\"}"}}

#burkeblack (44338537): swiftyspiffy(40876073): 1 (
47480) bits

and a bunch, with assembly verification:

Connecting!
ASSEMBLY: TwitchLib.PubSub, Version=3.2.3.0, Culture=neutral, PublicKeyToken=null
Connected!
[ListenResponse] #44338537: True
#burkeblack (44338537): swiftyspiffy(40876073): 1 (47484) bits
#burkeblack (44338537): swiftyspiffy(40876073): 1 (47485) bits
#burkeblack (44338537): swiftyspiffy(40876073): 1 (47485) bits
#burkeblack (44338537): swiftyspiffy(40876073): 1 (47487) bits
#burkeblack (44338537): swiftyspiffy(40876073): 1 (47488) bits
#burkeblack (44338537): swiftyspiffy(40876073): 1 (47488) bits
#burkeblack (44338537): swiftyspiffy(40876073): 1 (47490) bits
#burkeblack (44338537): swiftyspiffy(40876073): 1 (47491) bits

@swiftyspiffy
Copy link
Member

Using channel points:

Connecting!
ASSEMBLY: TwitchLib.PubSub, Version=3.2.3.0, Culture=neutral, PublicKeyToken=null
Connected!
[LOG] {"type":"RESPONSE","error":"","nonce":"vdW0bdtU"}

[ListenResponse] #44338537: True, channel-points-channel-v1.44338537
[LOG] {"type":"MESSAGE","data":{"topic":"channel-points-channel-v1.44338537","message":"{\"type
\":\"reward-redeemed\",\"data\":{\"timestamp\":\"2021-06-19T19:18:18.177773147Z\",\"redemption\
":{\"id\":\"79a64d91-ecb3-4f20-89ec-a3f204d9e0f5\",\"user\":{\"id\":\"40876073\",\"login\":\"sw
iftyspiffy\",\"display_name\":\"swiftyspiffy\"},\"channel_id\":\"44338537\",\"redeemed_at\":\"2
021-06-19T19:18:18.177773147Z\",\"reward\":{\"id\":\"dad42408-6ccf-48c9-ae1d-e47063cad4ab\",\"c
hannel_id\":\"44338537\",\"title\":\"Suggest a Poll\",\"prompt\":\"Suggest a poll to be ran on 
stream\",\"cost\":15000,\"is_user_input_required\":true,\"is_sub_only\":false,\"image\":null,\"
default_image\":{\"url_1x\":\"https://static-cdn.jtvnw.net/custom-reward-images/bulb-1.png\",\"
url_2x\":\"https://static-cdn.jtvnw.net/custom-reward-images/bulb-2.png\",\"url_4x\":\"https://
static-cdn.jtvnw.net/custom-reward-images/bulb-4.png\"},\"background_color\":\"#E91916\",\"is_e
nabled\":true,\"is_paused\":false,\"is_in_stock\":true,\"max_per_stream\":{\"is_enabled\":false
,\"max_per_stream\":1},\"should_redemptions_skip_request_queue\":false,\"template_id\":\"templa
te:a82f29bc-0b8f-42a9-888f-611b2099345e\",\"updated_for_indicator_at\":\"2020-04-24T03:32:33.57
1068054Z\",\"max_per_user_per_stream\":{\"is_enabled\":false,\"max_per_user_per_stream\":0},\"g
lobal_cooldown\":{\"is_enabled\":false,\"global_cooldown_seconds\":0},\"redemptions_redeemed_cu
rrent_stream\":null,\"cooldown_expires_at\":null},\"user_input\":\"Test test test\",\"status\":
\"UNFULFILLED\"}}}"}}

[OnChannelPointsRewardRedeemed] channel id: 44338537, user swiftyspiffy (swiftyspiffy) redeemed
 TwitchLib.PubSub.Models.Responses.Messages.Redemption.Reward (status: UNFULFILLED) at 6/19/202
1 7:18:18 PM
[LOG] {"type":"MESSAGE","data":{"topic":"channel-points-channel-v1.44338537","message":"{\"type\":\"reward-redeemed\",\"data\":{\"timestamp\":\"2021-06-19T19:20:56.278298646Z\",\"redemption\":{\"id\":\"c9ebe8f9-7fc2-46dd-8202-fa6c26f7b5bd\",\"user\":{\"id\":\"40876073\",\"login\":\"swiftyspiffy\",\"display_name\":\"swiftyspiffy\"},\"channel_id\":\"44338537\",\"redeemed_at\":\"2021-06-19T19:20:56.278298646Z\",\"reward\":{\"id\":\"dad42408-6ccf-48c9-ae1d-e47063cad4ab\",\"channel_id\":\"44338537\",\"title\":\"Suggest a Poll\",\"prompt\":\"Suggest a poll to be ran on stream\",\"cost\":15000,\"is_user_input_required\":true,\"is_sub_only\":false,\"image\":null,\"default_image\":{\"url_1x\":\"https://static-cdn.jtvnw.net/custom-reward-images/bulb-1.png\",\"url_2x\":\"https://static-cdn.jtvnw.net/custom-reward-images/bulb-2.png\",\"url_4x\":\"https://static-cdn.jtvnw.net/custom-reward-images/bulb-4.png\"},\"background_color\":\"#E91916\",\"is_enabled\":true,\"is_paused\":false,\"is_in_stock\":true,\"max_per_stream\":{\"is_enabled\":false,\"max_per_stream\":1},\"should_redemptions_skip_request_queue\":false,\"template_id\":\"template:a82f29bc-0b8f-42a9-888f-611b2099345e\",\"updated_for_indicator_at\":\"2020-04-24T03:32:33.571068054Z\",\"max_per_user_per_stream\":{\"is_enabled\":false,\"max_per_user_per_stream\":0},\"global_cooldown\":{\"is_enabled\":false,\"global_cooldown_seconds\":0},\"redemptions_redeemed_current_stream\":null,\"cooldown_expires_at\":null},\"user_input\":\"test test test\",\"status\":\"UNFULFILLED\"}}}"}}

[OnChannelPointsRewardRedeemed] channel id: 44338537, user swiftyspiffy (swiftyspiffy) redeemed TwitchLib.PubSub.Models.Responses.Messages.Redemption.Reward (status: UNFULFILLED) at 6/19/2021 7:20:56 PM
[LOG] { "type": "PONG" }

@swiftyspiffy
Copy link
Member

I'm not able to recreate :(

@Layla-P
Copy link

Layla-P commented Nov 24, 2021

I was doing some bug fixing on a project using the the latest verson today as my bot wasn't receiving any rewards. I received a "bad auth" as the error when I tried to add the listener.
I went to an old bot which does work, upgraded to the latest version, changed out the obsolete events and boom, it doesn't work either.
Any ideas?

@swiftyspiffy
Copy link
Member

Can you share the relevant code (without access tokens ofc). I can try recreating what you're getting too.

@Vlad0sZ
Copy link
Author

Vlad0sZ commented Nov 25, 2021

I was doing some bug fixing on a project using the the latest verson today as my bot wasn't receiving any rewards. I received a "bad auth" as the error when I tried to add the listener. I went to an old bot which does work, upgraded to the latest version, changed out the obsolete events and boom, it doesn't work either. Any ideas?

Hi! You need the channel owner's oauth token that you want to listen to. https://dev.twitch.tv/docs/authentication#getting-tokens
Don't forget to indicate scopes
https://dev.twitch.tv/docs/authentication#scopes

In my app, first Im get access token with user authorization. Use this lib
https://github.com/TwitchLib/TwitchLib.Api/tree/master/TwitchLib.Api/Auth

And, You can ask a question in discord, they helped me there quickly https://discord.gg/8NXaEyV

@swiftyspiffy
Copy link
Member

I'll post in both places, but I think (not certain) the issue here is that Twitch will only send pubsub channel point reward redemption events for channel points rewards created with the client id whos token you're using to connect to pubsub with. This means that you can't create channel points rewards through the website and then listen to them programmatically. What you'll need to do is:

  1. Instantiate TwitchLib.Api client with the same client id that generates the token you're using for PubSub
  2. Call (add additional parameters if you want):
    var resp = await api.Helix.ChannelPoints.CreateCustomRewardsAsync("channel-id", new 
    TwitchLib.Api.Helix.Models.ChannelPoints.CreateCustomReward.CreateCustomRewardsRequest
             {
                 Title = "My test reward!",
                 Cost = 10,
                 IsEnabled = true
             });
    
  3. Now have your pubsub listen to channel points events, and it should capture all of the redemptions for the rewards you created above.

Docs:

Logs from me testing this functionality:

[API] Reward created with id: 3cada83d-7aa7-47fe-b336-6cd46ec9c2a1
[LOG] {"type":"RESPONSE","error":"","nonce":"GXVDefVH"}

LISTEN RESPONSE: successful: True, nonce: GXVDefVH
[LOG] {"type":"MESSAGE","data":{"topic":"channel-points-channel-v1.36928113","message":"{\"type\":\"reward-redeemed\",\"data\":{\"timestamp\":\"2021-11-25T21:40:38.792959928Z\",\"redemption\":{\"id\":\"366c85d5-06e6-4e7d-9143-ee6cd7d42090\",\"user\":{\"id\":\"40876073\",\"login\":\"swiftyspiffy\",\"display_name\":\"swiftyspiffy\"},\"channel_id\":\"36928113\",\"redeemed_at\":\"2021-11-25T21:40:38.792959928Z\",\"reward\":{\"id\":\"3cada83d-7aa7-47fe-b336-6cd46ec9c2a1\",\"channel_id\":\"36928113\",\"title\":\"My test reward!\",\"prompt\":\"\",\"cost\":10,\"is_user_input_required\":false,\"is_sub_only\":false,\"image\":null,\"default_image\":{\"url_1x\":\"https://static-cdn.jtvnw.net/custom-reward-images/default-1.png\",\"url_2x\":\"https://static-cdn.jtvnw.net/custom-reward-images/default-2.png\",\"url_4x\":\"https://static-cdn.jtvnw.net/custom-reward-images/default-4.png\"},\"background_color\":\"#9147FF\",\"is_enabled\":true,\"is_paused\":false,\"is_in_stock\":true,\"max_per_stream\":{\"is_enabled\":false,\"max_per_stream\":0},\"should_redemptions_skip_request_queue\":false,\"template_id\":null,\"updated_for_indicator_at\":\"2021-11-25T21:28:03.908782554Z\",\"max_per_user_per_stream\":{\"is_enabled\":false,\"max_per_user_per_stream\":0},\"global_cooldown\":{\"is_enabled\":false,\"global_cooldown_seconds\":0},\"redemptions_redeemed_current_stream\":null,\"cooldown_expires_at\":null},\"status\":\"UNFULFILLED\"}}}"}}

Redeemed in 36928113
 - timestamp: 11/25/2021 9:40:38 PM
 - redemption id: 366c85d5-06e6-4e7d-9143-ee6cd7d42090

@RootShinobi
Copy link

it looks like ListenToChannelPoints requires a channel owner token. use ListenToRewards instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants