OAuth2ClientBuilder

class OAuth2ClientBuilder(issuerUrl: String, clientId: String, scope: List<String>)

A Java-idiomatic builder for creating instances of OAuth2Client.

This builder provides method-chaining setters for optional parameters and delegates to the Kotlin OAuth2ClientBuilder for the actual construction.

Pass the base org URL as issuerUrl and optionally call setAuthorizationServerId to target a custom authorization server. The effective issuer URL used for OIDC discovery is derived as:

  • No authorization server ID: issuerUrl is used as-is (org authorization server).

  • With authorization server ID: "$issuerUrl/oauth2/$authorizationServerId" (custom authorization server).

Parameters

issuerUrl

The base URL of the Okta org (e.g. "https://your-domain.okta.com"). Must use HTTPS.

clientId

The client ID of the application.

scope

The OAuth 2.0 scopes the application is requesting.

Constructors

Link copied to clipboard
constructor(issuerUrl: String, clientId: String, scope: List<String>)

Functions

Link copied to clipboard

Creates an OAuth2Client instance with the configured parameters.

Link copied to clipboard

Sets the access token validator. When set, access tokens are validated via at_hash claim.

Link copied to clipboard

Sets the ACR values.

fun setAllowPushedAuthorizationRequestFallback(allowPushedAuthorizationRequestFallback: Boolean): OAuth2ClientBuilder

Allows browser-based authorization flows to fall back to the classic authorization URL when PAR is optional and unavailable/fails.

Link copied to clipboard

Sets the HTTP executor used for all network requests.

Link copied to clipboard

Sets the authorization server ID used to target a custom authorization server.

Link copied to clipboard

Sets the cache for optimizing network calls.

Link copied to clipboard

Sets the provider for private_key_jwt (or similar JWT-based) client authentication.

Link copied to clipboard

Sets the client secret for confidential clients.

Link copied to clipboard

Sets the clock used for time-sensitive operations.

Link copied to clipboard

Sets the dispatcher for compute-bound operations.

Link copied to clipboard

Sets the device secret validator. When set, device secrets are validated via ds_hash claim.

Link copied to clipboard
fun setEnablePushedAuthorizationRequests(enablePushedAuthorizationRequests: Boolean): OAuth2ClientBuilder

Enables Pushed Authorization Requests (PAR) for browser-based authorization flows.

Link copied to clipboard

Sets optional per-endpoint URL overrides.

Link copied to clipboard

Sets the ID token validator. When set, ID tokens are validated after token refresh.

Link copied to clipboard

Sets the dispatcher for IO-bound operations.

Link copied to clipboard
fun setJson(json: Json): OAuth2ClientBuilder

Sets the JSON serializer used for encoding/decoding responses.

Link copied to clipboard
fun setRateLimitRetryCallback(rateLimitRetryCallback: (retryCount: Int) -> RateLimitRetryConfig?): OAuth2ClientBuilder

Sets the callback invoked when an HTTP 429 rate-limit response is received.