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

RefreshableAuthProvider

Enhances another auth provider with the ability to make use of refresh tokens, automatically refreshing the access token whenever necessary.

Overview

Constructor

new RefreshableAuthProvider(childProvider, refreshConfig)

Creates a new auth provider based on the given one that can automatically refresh access tokens.

ParameterTypeRequiredDefaultDescription
childProviderAuthProvidernone

The base auth provider.

refreshConfigRefreshConfignone

The information necessary to automatically refresh an access token.

Properties

clientId

Type: string

The client ID.

currentScopes

Type: Array<string>

The scopes that are currently available using the access token.

tokenType

Type: ?AuthProviderTokenType

The type of tokens the provider generates.

It is the same as the underlying base auth provider's token type.

Methods

getAccessToken(scopes)

async

Retrieves an access token.

If the current access token does not have the requested scopes, the base auth provider is called.

If the current access token is expired, automatically renew it.

ParameterTypeRequiredDefaultDescription
scopesstring | Array<string>none

The requested scopes.

Return type: AccessToken | null

refresh()

async

Force a refresh of the access token.

Return type: AccessToken