1.0.2 • Published 6 years ago
@updownleftdie/twitch-oauth-helper v1.0.2
Twitch OAuth Helper
Currently only supports OAuth Authorization Code Flow
Usage
const getTwitchSession = require("./index");
const twitchSession = await getTwitchSession({
clientId: "...",
clientSecret: "...",
redirectUri: "http://localhost",
});- On initial call will help obtain
accessTokenandrefreshTokens by providing a link to gain authorization code and wait for user input.- This can be skipped by building your own
twitch-session.jsonwith twitchtokengenerator.com
- This can be skipped by building your own
- When called it will check and automatically refresh a token based on expiration time.
Returns
{
"clientId": "...",
"accessToken": "...",
"refreshToken": "...",
"expires": "2020-05-11T01:00:00.000Z"
}Parameters
getTwitchSession(settings, forceRefresh)
| parameter | key | description |
|---|---|---|
| settings | clientId | Twitch App Client ID |
| settings | clientSecret | Twitch App Secret |
| settings | redirectUri | (Optional) Where initial authorization request should redirect too |
| settings | scope | (Optional) space-separated list of scopes |
| forceRefresh | (Optional) Forces the accessToken to be refreshed |