Skip to main content

@wildix/auth-utils > ServiceTokenProvider

ServiceTokenProvider class

The ServiceTokenProvider class is a token provider implementation that facilitates the retrieval of access tokens for a service.

Example Usage:

const clientId = 'yourClientId';
const clientSecret = 'yourClientSecret';
const tokenProvider = new ServiceTokenProvider(clientId, clientSecret);

try {
const accessToken = await tokenProvider.token();
console.log('Access Token:', accessToken);
} catch (error) {
console.error('Error retrieving access token:', error);
}

The implementation encapsulates the logic for obtaining and caching access tokens securely, abstracting away the details of the authentication process.

Signature:

export declare class ServiceTokenProvider implements TokenProvider 

Implements: TokenProvider

Constructors

Constructor

Modifiers

Description

(constructor)(clientId, clientSecret, scope, env)

Constructs a new instance of the ServiceTokenProvider class

Properties

Property

Modifiers

Type

Description

cachedToken

string | undefined

cachedTokenTtl

number | undefined

clientId

string

clientSecret

string

env

ServiceTokenEnv

scope

ServiceTokenScope | undefined

Methods

Method

Modifiers

Description

token()