Skip to main content
Version: 1.12.0

Class: CantonClientCredentialsProvider

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

Client credentials auth provider.

Uses a CachingTokenSource so the first tokenSource().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:64

The auth scheme this provider was built from.

Implementation of

CantonAuthProvider.type

Methods

tokenSource()

tokenSource(): CantonTokenSource

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

Returns the caching token source.

Returns

CantonTokenSource

Implementation of

CantonAuthProvider.tokenSource


fromDirect()

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

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

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:123

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