twitcheasy-twitch-bottwitch-authtwitch-auth-tmitwitch-chat-clienttwitch-eventsubtwitch-pubsub-clienttwitch-webhooks

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, tokenType)

Creates a new auth provider with static credentials.

ParameterTypeRequiredDefaultDescription
clientIdstringnone

The client ID.

accessTokenstring | AccessTokennone

The access token to provide.

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

scopesArray<string>none

The scopes the supplied token has.

tokenTypeAuthProviderTokenType"user"

The type of the supplied token.

Properties

tokenType

Type: AuthProviderTokenType

The type of token the provider holds.

clientId

Type: string

The client ID.

currentScopes

Type: Array<string>

The scopes that are currently available using the access token.

Methods

getAccessToken(scopes)

async

Retrieves an 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
scopesstring | Array<string>none

The requested scopes.

Return type: AccessToken | null