Skip to main content
Version: 1.15.0

Class: CantonClientCredentialsProvider

Defined in: canton/authentication/client-credentials.ts:58

Client credentials auth provider.

Uses a memoized token fetcher (micro-memoize with { async: true, expires }) so the first token() call fetches a token and subsequent calls return the cached value until it expires.

Implements​

Properties​

type​

readonly type: "clientCredentials"

Defined in: canton/authentication/client-credentials.ts:59

The auth scheme this provider was built from.

Implementation of​

CantonAuthProvider.type

Methods​

token()​

token(): Promise<AccessToken>

Defined in: canton/authentication/client-credentials.ts:70

Returns a valid access token, fetching via the client credentials grant if needed.

Returns​

Promise<AccessToken>

Implementation of​

CantonAuthProvider.token


fromDirect()​

static fromDirect(config: ClientCredentialsAuthConfig & { tokenUrl: string; }, options?: OAuthRequestOptions): ClientCredentialsProvider

Defined in: canton/authentication/client-credentials.ts:159

Create a provider with an explicit token endpoint URL (no discovery).

Suitable for environments where the token endpoint is known in advance. A minimal oauth4webapi.AuthorizationServer is constructed from the provided authUrl (issuer) and tokenUrl.

Parameters​

ParameterTypeDescription
configClientCredentialsAuthConfig & { tokenUrl: string; }Client credentials config plus a tokenUrl.
options?OAuthRequestOptionsOptional fetch override and abort signal.

Returns​

ClientCredentialsProvider

A ClientCredentialsProvider.

Throws​

CCIPError (CANTON_AUTH_ERROR) on invalid config.


fromDiscovery()​

static fromDiscovery(config: ClientCredentialsAuthConfig, options?: OAuthRequestOptions): Promise<ClientCredentialsProvider>

Defined in: canton/authentication/client-credentials.ts:118

Create a provider using OAuth2 Authorization Server Metadata discovery (RFC 8414) to automatically locate the token endpoint.

This is the recommended approach when the authorization server supports metadata discovery, as it eliminates the need to manually specify the token endpoint URL.

Parameters​

ParameterTypeDescription
configClientCredentialsAuthConfigClient credentials config with authUrl (authorization server base URL).
options?OAuthRequestOptionsOptional fetch override and abort signal.

Returns​

Promise<ClientCredentialsProvider>

A ClientCredentialsProvider.

Throws​

CCIPError (CANTON_AUTH_ERROR) on discovery failure or invalid config.

See​

https://datatracker.ietf.org/doc/html/rfc8414