OAuth2

data class OAuth2(val variant: AuthCredential.OAuth2.Variant = Variant.OAUTH2, val clientId: String? = null, val clientSecret: Secret? = null, val authUri: String? = null, val nonce: String? = null, val state: String? = null, val redirectUri: String? = null, val authResponseUri: Secret? = null, val authCode: Secret? = null, val accessToken: Secret? = null, val refreshToken: Secret? = null, val idToken: Secret? = null, val expiresAt: Instant? = null, val expiresIn: Duration? = null, val audience: String? = null, val prompt: String? = null, val codeVerifier: Secret? = null, val codeChallengeMethod: String? = null, val tokenEndpointAuthMethod: AuthCredential.OAuth2.TokenEndpointAuthMethod? = TokenEndpointAuthMethod.CLIENT_SECRET_BASIC) : AuthCredential

An OAuth2 or OpenID Connect credential: the client's configuration, the sign-in state and, once the user has signed in, the tokens.

Constructors

Link copied to clipboard
constructor(variant: AuthCredential.OAuth2.Variant = Variant.OAUTH2, clientId: String? = null, clientSecret: Secret? = null, authUri: String? = null, nonce: String? = null, state: String? = null, redirectUri: String? = null, authResponseUri: Secret? = null, authCode: Secret? = null, accessToken: Secret? = null, refreshToken: Secret? = null, idToken: Secret? = null, expiresAt: Instant? = null, expiresIn: Duration? = null, audience: String? = null, prompt: String? = null, codeVerifier: Secret? = null, codeChallengeMethod: String? = null, tokenEndpointAuthMethod: AuthCredential.OAuth2.TokenEndpointAuthMethod? = TokenEndpointAuthMethod.CLIENT_SECRET_BASIC)

Types

Link copied to clipboard
class Builder

Fluent builder for OAuth2, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.

Link copied to clipboard
object Companion
Link copied to clipboard

The way an OAuth2 client authenticates to the token endpoint (RFC 7591 section 2).

Link copied to clipboard

The protocol of an OAuth2 credential, OAuth2 or OpenID Connect; both carry the same fields.

Properties

Link copied to clipboard

The access token that authorizes the tool's calls to the service.

Link copied to clipboard

The audience to request a token for.

Link copied to clipboard

The authorization code the provider returned, which the token exchange trades for tokens.

Link copied to clipboard

The full redirect URL the provider returned, including the code.

Link copied to clipboard

Where to send the user to sign in.

Link copied to clipboard

The OAuth2 client ID.

Link copied to clipboard

The OAuth2 client secret; absent for a public client.

Link copied to clipboard

The PKCE code-challenge method; only S256 is supported.

Link copied to clipboard

The PKCE code verifier, sent with authCode to the token endpoint.

Link copied to clipboard

When the access token expires.

Link copied to clipboard

The access token's lifetime, as the token response gives it.

Link copied to clipboard

The OpenID Connect ID token, which identifies the signed-in user.

Link copied to clipboard

The nonce parameter of the authorization request, which ties the request to the user's session.

Link copied to clipboard

The prompt parameter of the authorization request.

Link copied to clipboard

Where the provider sends the user after signing in.

Link copied to clipboard

The refresh token, which gets a new access token when accessToken expires.

Link copied to clipboard

The state value that ties the provider's redirect to this sign-in.

Link copied to clipboard

How the client authenticates to the token endpoint; null leaves the choice to the token exchange.

Link copied to clipboard

Whether this is an OAuth2 or an OpenID Connect credential.

Functions

Link copied to clipboard

Returns expiresIn truncated to whole seconds, or null if it is unset. Java callers use it because they can't call the Duration getter.

Link copied to clipboard

Returns a Builder initialized with this instance's properties, primarily for Java callers. Prefer it over copy from Java: copy takes every property positionally, so its signature changes whenever a property is added.

Link copied to clipboard
open override fun toString(): String