I’m trying to develop an application that can get notifications when someone follows or subscribes to a channel. However, I cannot seem to get the client credentials access token needed to subscribe to the events.
Simply making the request in the command line like this:
with CLIENT_ID and CLIENT_SECRET being the keys I generated when I registered my app at https://dev.twitch.tv/console stored as environment variables
I have read that this means that the client ID isn’t valid, however, even making a new application and generating new codes yields the same results. Manually entering the codes instead of using environment variables also yields the same result. I am 100% certain I have been entering the client ID properly.
Is there anything else I am doing wrong? Getting the OAuth token for users (for making chatbots) seems to work fine, but app tokens are not working for me.
Additionally, as subscriptions is private data you’ll also need to use either the Implicit or Auth Code OAuth flows with the user you wish to get notifications for so that they grant your app that permission, otherwise when you try to use the App token to subscribe to EventSub for notifications it will deny you the ability to listen for subscriptions.
You omitted a -X POST so you made a GET request instead of a POST request.
curl -X POST https://id.twitch.tv/oauth2/token?client_id=MYCID&client_secret=MYSECRET&grant_type=client_credentials
So no need to pass as -d variables here really
So that’ll fix you for getting a Client Credentials token but as dist notes, this doesn’t work for subscriptions data, unless your ClientID is an Extension and the streamer has that extension installed with Subscription Permissions enabled
-X Post yields the same result as well, unfortunately.
Also, the documentation you linked says that data “Gets a list of users that subscribe to the specified broadcaster.” which is not what I want, but rather, simply a notification of when a channel gets a new subscriber with the notification type “channel.subscribe” which is similar to “channel.follow”. Could I not get that notification information with the broadcaster’s user access token (since it states " Must have channel:read:subscriptions scope."?) (Also, the app is an offline standalone application, with a place for the user/broadcaster to enter in credentials manually rather than going through the app extension page).
First you create a permission link between your clientID and the streamer for whatever scopes/permissions you need,
Then you use an App Access Token to generate the EventSub Subscriptions.
Keep the user token on file if you need to catch up.
EventSub is a “dual token” scenario.
But as to your OP
I would consume subscriptions (and resubs and primes) from chat.
And follows from EventSub.
Oh yeah, I forgot about that, though that’d still be nicer than having to juggle two webhooks.
And yeah I see, that’s pretty cool you can send notifications to viewers, and since the bot is a viewer technically, it’s kind of a nice workaround. I have a chatbot set up in my app (it’s a throwaway account with the Oauth token hardcoded in), so this might workout a bit cleaner.
Thanks and hopefully I can get this token cleanly.