Authorizing application for Eventsub Subscription

Hello all, hopefully this isn’t too repetitive but I haven’t been able to find an exact solution to the issue I’m facing.

I’m using Golang and HelixV2 to interface with the Twitch API to capture twitch events, but I’m having an issue getting the EventSub subscription created correctly. I’ve been able to call the API in general for basic things like these two calls

resp, err := helixClient.GetUsers(&helix.UsersParams{
		Logins: []string{"whitegrimreaper_"},
	})

eventSubResp, err := helixClient.GetEventSubSubscriptions(&helix.EventSubSubscriptionsParams{
		Status: helix.EventSubStatusEnabled, // This is optional.
	})

but I seem to be having an issue with the Oauth authorization. I saw this thread and have done a request through both the auth code flow and client credentials flow but neither of those access tokens seems to work correctly. Same is true for this other thread discussing the same topic. After doing the auth flow and getting a new app access token from the client credentials flow, I still get a subscription missing proper authorization error.

I’ve followed the Auth code flow and allowed access for my app (I can see the app in my account Connections), but no matter which token I use I still cannot subscribe to Eventsub. The relevant calls are below, ClientID and ClientSecret are from the app dashboard, broadcaster and bot ids are the twitch ids for my channel and bot account respectively, and AppAccessToken I have tried to switch between every Oauth token I’ve gotten at any stage in the process and none of them work.

helixClient, err := helix.NewClient(&helix.Options{
		ClientID: clientId,
		ClientSecret: clientSecret,
		AppAccessToken: accessToken,
	})
resp, err := client.CreateEventSubSubscription(&helix.EventSubSubscription{
		Type: helix.EventSubTypeChannelFollow,
		Version: "2",
		Condition: helix.EventSubCondition{
			BroadcasterUserID: os.Getenv("BROADCASTER_ID"),
			ModeratorUserID: os.Getenv("BOT_ID"),
		},
		Transport: helix.EventSubTransport{
			Method: "webhook",
			Callback: "https://localhost:443",
			Secret: "aaaaaa",
		},
	})

That topic requires the moderator:read:followers scope. Has the moderator account connected to your app through the Implicit or Auth Code flows and granted that scope?

Or to put it another way

  1. Ask a moderator (or better) of the channel to generate a user access token with the moderator:read:followers scope
  2. Throw away the resultant token
  3. Generate a Client Credentials token
  4. Make a request to the topic with the state conditions

Twitch then checks if the moderator_user_id in the condition has in the past granted a user token with the needed scopes to the client ID, and checks if the moderator_user_id is a moderator or better of broadcaster_user_id

As dist notes, it seems the moderator_user_id in your condition hasn’t done that, or the moderator_user_id isn’t a moderator or better on broadcaster_user_id

Ah you were totally correct, I thought I had read through the Scopes and I think I missed adding that scope, once I authorized with the bot account as well (which already was a moderator, but I was doing the auth code flow on my main account instead) and added that tag, everything started working as expected!

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