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.

Parameter Type Required Default Description
clientId string none

The client ID.

accessToken string | AccessToken none

The access token to provide.

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

scopes Array<string> none

The scopes the supplied token has.

tokenType
AuthProviderTokenType

The type of token an auth provider can return - user tokens and app tokens are supported.

Aliased type: "user" | "app"

"user"

The type of the supplied token.

Properties

tokenType

Type:
AuthProviderTokenType

The type of token an auth provider can return - user tokens and app tokens are supported.

Aliased type: "user" | "app"

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.

Parameter Type Required Default Description
scopes string | Array<string> none

The requested scopes.

Return type: AccessToken | null