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.

Parameter Type Required Default Description
childProvider AuthProvider none

The base auth provider.

refreshConfig RefreshConfig none

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 token an auth provider can return - user tokens and app tokens are supported.

Aliased type: "user" | "app"

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.

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

The requested scopes.

Return type: AccessToken | null

refresh()

async

Force a refresh of the access token.

Return type: AccessToken