Twitch standalone EventSub server
This is a single-file standalone app to subscribe to EventSub twitch API.
Just fill-in the IDs as described bellow and run the server.
Check the console's logs, you may be asked to open an URL on your browser to grant access to configured scopes to your app the first time you run the server.
Just do anything you want on the onEvent()
method. This is the function that'll be called everytime twitch sends an event.
Install dependencies
Run the following command on the folder's root :
npm install
Accounts settings
NGrok
Create an account on https://ngrok.com and get an auth token. Works with a free account.
Set the token as the NGROK_AUTH_TOKEN
var value.
Twitch app
-
Create a twitch application here https://dev.twitch.tv/console.
Get the Client ID and the Secret Client and set these values on theTWITCH_CLIENT_ID
andTWITCH_CLIENT_SECRET
vars.
On the app you must also configure an OAuth redirect URI.
Configure this URL:
http://localhost:3000/oauth
(make sure the port is the same as the one configured on the varSERVER_PORT
) -
Define the events you want to subscribe to on the
EVENTS_TO_SUB_TO
var.
See full events list here :
https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types -
Set your twitch user ID on the
TWITCH_BROADCASTER_ID
var.
You can get your twitch ID from your twitch name via this page. -
Define a
TWITCH_EVENTSUB_SECRET
key. Just write anything you want as a value. Anything genitally related will do😏 . -
Finally, you must define the scopes that your twitch app will be granted access to in the
TWITCH_SCOPES
var.
The avaiable scopes are described on every event's descriptions of this page.
Run server
Once you configured everything as listed above, just run the server :
node index.js
On first run the console should log an URL to authorize the app with specified scopes.
Jst open that URL on your browserr, click "accept" and your app will be granted access to everything.
If you later request a new scope/event, the same message will be displayed.