TwurpleAuthenticationGetting dataExamplesFAQMigration

AppTokenAuthProvider

An auth provider that gets tokens using client credentials.

Overview

Constructor

new AppTokenAuthProvider(clientId, clientSecret, impliedScopes)

Creates a new auth provider to receive an application token with using the client ID and secret.

ParameterTypeRequiredDefaultDescription
clientIdstringnone

The client ID of your application.

clientSecretstringnone

The client secret of your application.

impliedScopesstring[]<complex>

The scopes that are implied for your application, for example an extension that is allowed to access subscriptions.

Properties

clientId

Type: string

The client ID.

currentScopes

Type: string[]

The scopes that are currently available using the access token.

Methods

getAccessTokenForUser(user, scopeSets)

async

Can only get tokens for implied scopes (i.e. extension subscription support).

The consumer is expected to take care that this is actually set up in the Twitch developer console.

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

The user to get an access token for.

scopeSets(?string[])[]none

The requested scopes.

getAnyAccessToken()

async

Fetches an app access token.

Return type: AccessToken

getAppAccessToken(forceNew)

async

Fetches an app access token.

ParameterTypeRequiredDefaultDescription
forceNewbooleanfalse

Whether to always get a new token, even if the old one is still deemed valid internally.

Return type: AccessToken

getCurrentScopesForUser()

Throws, because this auth provider does not support user authentication.

Return type: string[]