TwurpleAuthenticationGetting dataExamplesFAQMigration

StaticAuthProvider

An auth provider that always returns the same initially given credentials.

Overview

You are advised to roll your own auth provider that can handle scope upgrades, or to plan ahead and supply only access tokens that account for all scopes you will ever need.

Constructor

new StaticAuthProvider(clientId, accessToken, scopes)

Creates a new auth provider with static credentials.

ParameterTypeRequiredDefaultDescription
clientIdstringnone

The client ID of your application.

accessTokenstring | AccessTokennone

The access token to provide.

You need to obtain one using one of the Twitch OAuth flows.

scopesstring[]none

The scopes the supplied token has.

If this argument is given, the scopes need to be correct, or weird things might happen. If it's not (i.e. it's undefined), we fetch the correct scopes for you.

If you can't exactly say which scopes your token has, don't use this parameter/set it to undefined.

Properties

clientId

Type: string

The client ID.

Methods

getAccessTokenForIntent(intent, scopeSets)

async

Gets the static access token.

If the current access token does not have the requested scopes, this method throws. This makes supplying an access token with the correct scopes from the beginning necessary.

ParameterTypeRequiredDefaultDescription
intentstringnone

Ignored.

scopeSets(?string[])[]none

The requested scopes.

getAccessTokenForUser(user, scopeSets)

async

Gets the static access token.

If the current access token does not have the requested scopes, this method throws. This makes supplying an access token with the correct scopes from the beginning necessary.

ParameterTypeRequiredDefaultDescription
user
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

Ignored.

scopeSets(?string[])[]none

The requested scopes.

getAnyAccessToken()

async

Gets the static access token.

getCurrentScopesForUser()

The scopes that are currently available using the access token.

Return type: string[]