If you, like me, are running chatbots and other streaming tools, you’ll need an OAuth token as of May 11, 2020.
I built this helper to create a convenient way to quickly get that access token for use in my various streaming bots and apps.
# install the package
npm i @jlengstorf/get-twitch-oauth
TWITCH_CLIENT_ID=<YOUR_TWITCH_CLIENT_ID>
TWITCH_CLIENT_SECRET=<YOUR_TWITCH_CLIENT_SECRET>
const { getTwitchAccessToken } = require('@jlengstorf/get-twitch-oauth');
const { access_token } = getTwitchAccessToken();
For a more complete example, see demo/index.js
.
param | required | default | description |
---|---|---|---|
client_id |
no | process.env.TWITCH_CLIENT_ID |
your Twitch app’s client ID |
client_secret |
no | process.env.TWITCH_CLIENT_SECRET |
your Twitch app’s client secret |
grant_type |
no | "client_credentials" |
for app-to-app tokens, this must be "client_credentials" |
scopes |
no | "" |
any permission scopes required by your app |