OAuth2ClientBuilder
Builder for creating an OAuth2Client.
Use the create factory method to construct an instance.
Pass the base org URL as issuerUrl and optionally set authorizationServerId to target a custom authorization server. The effective issuer URL used for OIDC discovery is derived as:
No authorizationServerId:
issuerUrlis used as-is (org authorization server).With authorizationServerId:
"$issuerUrl/oauth2/$authorizationServerId"(custom authorization server).
// Org authorization server
val orgClient = OAuth2ClientBuilder.create(
issuerUrl = "https://your-okta-domain.okta.com",
clientId = "your-client-id",
scope = listOf("openid", "profile", "offline_access"),
).getOrThrow()
// Custom authorization server
val customClient = OAuth2ClientBuilder.create(
issuerUrl = "https://your-okta-domain.okta.com",
clientId = "your-client-id",
scope = listOf("openid", "profile", "offline_access"),
) {
authorizationServerId = "default"
}.getOrThrow()Properties
Access token validator. When set, access tokens are validated via at_hash claim.
Allows browser-based authorization flows to fall back to the classic authorization URL when PAR is optional and unavailable/fails.
The HTTP executor used for all network requests.
Optional authorization server ID.
Optional provider for private_key_jwt (or similar JWT-based) client authentication.
Optional client secret for confidential clients.
The dispatcher for compute-bound operations.
Device secret validator. When set, device secrets are validated via ds_hash claim.
Enables Pushed Authorization Requests (PAR) for browser-based authorization flows.
Optional per-endpoint URL overrides.
ID token validator. When set, ID tokens are validated after token refresh.
The dispatcher for IO-bound operations.
Optional callback invoked when an HTTP 429 rate-limit response is received.