Eventsub set-up problems in C# (HttpClient/TwitchLib)

I have two problems related with the title:

  1. I was trying to follow this example: https://www.therelicans.com/wyhaines/twitch-eventsub-the-direct-approach-to-getting-started-with-it-3pia

in C#, By using HttpClient(), I was able to get an access token, but now I want to subscribe to
channel.follow event (following the step 1), but I don’t know How to create a POST request with objects as keys param.

I tried to do this

var requestContent = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair<string, string>("version", "1"),
                new KeyValuePair<string, string>("type", "channel.follow"),
                new KeyValuePair<string, string>("condition", "{\"broadcaster_user_id\": \"" + Config.DameInstancia().ClientID + "\"}"),
                new KeyValuePair<string, string>("transport", "{\"method\": \"webhook\",\"callback\":\"https://example.com/webhooks/callback\",\"secret\": \"" + Config.DameInstancia().Secret + "\"}")
            });

but it didn’t work xD. I keep getting the 401 status.

  1. I’ve tried to get the eventsub working in the “easy way”, using twitchlib.

This is the set-up I was trying to achieve with twitchlib https://githubmemory.com/repo/TwitchLib/TwitchLib.EventSub.Webhooks

but when I run it, it does nothing… so I guess I did something wrong…

It seems that the only thing i needed to do is to change the “supersecuresecret” for my twitch secret… but it is not working… I don’t really get the CallbackPath either… I undestand what it should do, but I don’t get How to set it up.

Well… let’s be the first one to answer this post:

for the first one: I was using an incorrect value for broadcaster_user_id, I was using ClientID, but is different (I didn’t know).

In the tutorial, it says that the header need parameters:

Client-ID: CLIENT_ID
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

but the third line was causing me exceptions. Removing it causes the http request to work… So I don’t know if I misundertstood something, or that part on the tutorial is wrong…

For the second one: I still don’t understand how this lib works, it doesn’t seem to be an standalone applicacion but it seems to work more like a webhook… so i’ll keep doing tests.

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