OAuth2Client

A cross-platform OAuth2 client for interacting with an Okta Authorization Server.

This client is storage-agnostic — it handles HTTP calls, token validation, and event emission but never persists tokens. To store tokens, use TokenCredentialManager:

// 1. Create the client
val client = OAuth2ClientBuilder.create(issuerUrl, clientId, scope).getOrThrow()

// 2. Perform a token request (e.g., from a flow class)
val tokenInfo = client.tokenRequest(formParams).getOrThrow()

// 3. Persist via TokenCredentialManager
val tokenData = TokenData(tokenInfo, client.configuration)
val credential = manager.store(tokenData).getOrThrow()

Use OAuth2ClientBuilder to create an instance via the builder pattern.

On Android, the existing OAuth2Client class provides backward-compatible access with additional platform-specific features.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The configuration for this client.

Link copied to clipboard
val events: ERROR CLASS: Symbol not found for SharedFlow<com/okta/authfoundation/events/Event>

A read-only flow of OAuth2 lifecycle events emitted by this client.

Functions

Link copied to clipboard
suspend fun deviceAuthorizationRequest(formParams: Map<String, String>): ERROR CLASS: Symbol not found for Result<com/okta/authfoundation/client/dto/DeviceAuthorizationInfo>

Performs a device authorization request per RFC 8628.

Link copied to clipboard
Link copied to clipboard
suspend fun getUserInfo(accessToken: String): ERROR CLASS: Symbol not found for Result<com/okta/authfoundation/client/dto/OidcUserInfo>

Performs the OIDC User Info call.

Link copied to clipboard
suspend fun introspectToken(tokenTypeHint: String, token: String): ERROR CLASS: Symbol not found for Result<com/okta/authfoundation/client/dto/IntrospectInfo>

Performs a call to the Authorization Server to validate the specified token per RFC 7662.

Link copied to clipboard
suspend fun jwks(): ERROR CLASS: Symbol not found for Result<com/okta/authfoundation/jwt/Jwks>

Performs a call to the Authorization Server to fetch the JSON Web Key Set.

Link copied to clipboard
suspend fun refreshToken(refreshToken: String): ERROR CLASS: Symbol not found for Result<com/okta/authfoundation/client/TokenInfo>

Attempt to refresh a token using the provided refresh token string.

Link copied to clipboard
suspend fun revokeToken(token: String): ERROR CLASS: Symbol not found for Result<kotlin/Unit>

Attempt to revoke the specified token.

Link copied to clipboard
suspend fun tokenRequest(formParams: Map<String, String>, nonce: String? = null, maxAge: Int? = null): ERROR CLASS: Symbol not found for Result<com/okta/authfoundation/client/TokenInfo>

Performs a token endpoint request with the given form parameters.