Credential

class Credential

Convenience object that wraps a Token, providing methods and properties for interacting with credential resources.

This class can be used as a convenience mechanism for managing stored credentials, performing operations on or for a user using their credentials, and interacting with resources scoped to the credential.

Functions

Link copied to clipboard
fun accessTokenInterceptor(): Interceptor

Returns an Interceptor that can be can be added to an OkHttpClient via OkHttpClient.Builder.addInterceptor to access a Resource Server.

Link copied to clipboard
suspend fun delete()

Removes this Credential from the associated CredentialDataSource. Also, sets the Token to null. This Credential should not be used after it's been removed.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
suspend fun getAccessTokenIfValid(): String?

Checks to see if the current access token is valid, and if it is, returns it. If there is no Token associated with the Credential, null is returned.

Link copied to clipboard
suspend fun getUserInfo(): OidcClientResult<OidcUserInfo>

Performs the OIDC User Info call, which returns claims associated with this Credential.

Link copied to clipboard
suspend fun getValidAccessToken(): String?

Returns a valid access token if one is present. If the access token is invalid, and there is a refresh token, a Token refresh is attempted via Credential.refreshToken. If the refresh results in a valid access token, it is returned.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
suspend fun idToken(): Jwt?

Retrieve the Jwt associated with the Token.idToken field.

Link copied to clipboard
suspend fun introspectToken(tokenType: TokenType): OidcClientResult<OidcIntrospectInfo>

Performs a call to the Authorization Server to validate the specified TokenType.

Link copied to clipboard
suspend fun refreshToken(): OidcClientResult<Token>

Attempt to refresh the Token associated with this Credential.

Link copied to clipboard
suspend fun revokeToken(tokenType: RevokeTokenType): OidcClientResult<Unit>

Attempt to revoke the specified TokenType.

Link copied to clipboard
fun scope(): String

Returns the scopes associated with the associated Token if present, otherwise the default scopes associated with the OidcClient.

Link copied to clipboard
suspend fun storeToken(token: Token? = _token, tags: Map<String, String> = _tags)

Store a token, or update the existing token. This can also be used to store custom tags.

Properties

Link copied to clipboard
val tags: Map<String, String>

The tags associated with this Credential.

Link copied to clipboard
val token: Token?

The current Token that's stored and associated with this Credential.