Adds custom client authentication to OAuth token requests.
This optional method allows implementations to customize how client credentials are included in token exchange and refresh requests. When provided, this method is called instead of the default authentication logic, giving full control over the authentication mechanism.
Common use cases include:
Metadata about this OAuth client.
The URL to redirect the user agent to after authorization.
Return undefined for non-interactive flows that don't require user interaction
(e.g., client_credentials, jwt-bearer).
Loads information about this OAuth client, as registered already with the
server, or returns undefined if the client is not registered with the
server.
Loads the PKCE code verifier for the current session, necessary to validate the authorization result.
Prepares grant-specific parameters for a token request.
This optional method allows providers to customize the token request based on the grant type they support. When implemented, it returns the grant type and any grant-specific parameters needed for the token exchange.
If not implemented, the default behavior depends on the flow:
code, code_verifier, and redirect_uriclient_credentials: detected via grant_types in clientMetadataOptionalscope: stringOptional scope to request
Grant type and parameters, or undefined to use default behavior
Invoked to redirect the user agent to the given URL to begin the authorization flow.
If implemented, this permits the OAuth client to dynamically register with
the server. Client information saved this way should later be read via
clientInformation().
This method is not required to be implemented if client information is statically known (e.g., pre-registered).
Saves a PKCE code verifier for the current session, before redirecting to the authorization flow.
Stores new OAuth tokens for the current session, after a successful authorization.
Loads any existing OAuth tokens for the current session, or returns
undefined if there are no saved tokens.
OAuth provider for
client_credentialsgrant withprivate_key_jwtauthentication.This provider is designed for machine-to-machine authentication where the client authenticates using a signed JWT assertion (RFC 7523 Section 2.2).
Example