@jlengstorf/get-twitch-oauth
v1.0.1
Published
If you, like me, are running chatbots and other streaming tools, you’ll need an OAuth token [as of May 11, 2020](https://discuss.dev.twitch.tv/t/requiring-oauth-for-helix-twitch-api-endpoints/23916).
Downloads
40
Readme
Get an Twitch OAuth Token for Server-to-Server Requests
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.
Quickstart
1. Install the package
# install the package
npm i @jlengstorf/get-twitch-oauth
2. Set environment variables
TWITCH_CLIENT_ID=<YOUR_TWITCH_CLIENT_ID>
TWITCH_CLIENT_SECRET=<YOUR_TWITCH_CLIENT_SECRET>
3. Get a token
const { getTwitchAccessToken } = require('@jlengstorf/get-twitch-oauth');
const { access_token } = getTwitchAccessToken();
For a more complete example, see demo/index.js
.
API
| 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 |