OAuthApi

class OAuthApi(httpClient: HttpClient, challengeSelector: OAuthCodeChallengeMethodSelector, random: Random = CryptographyRandom, clock: Clock = Clock.System)

Implementation to build a URL that will interact with a hosted OAuth service.

Parameters

httpClient

The HTTP client to use for requests.

challengeSelector

The strategy to select the code challenge method.

random

The random number generator to use for generating state and code challenges.

clock

The clock to use for generating timestamps.

Constructors

Link copied to clipboard
constructor(httpClient: HttpClient, challengeSelector: OAuthCodeChallengeMethodSelector, random: Random = CryptographyRandom, clock: Clock = Clock.System)

Construct a new OAuth API instance.

constructor()

Construct a new instance using the Bluesky OAuth client and always using the "S256" code challenge method.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun buildAuthorizationRequest(oauthClient: OAuthClient, scopes: List<OAuthScope>, loginHandleHint: String? = null): OAuthAuthorizationRequest

Build an authorization request for the given client and scopes. This URL can be used to redirect the user to the OAuth server to log into their account.

Link copied to clipboard
suspend fun createDpopHeaderValue(keyPair: DpopKeyPair, method: String, endpoint: String, nonce: String?, accessToken: String?): String

Create a value for the DPoP header to be used in requests to the OAuth server.

Link copied to clipboard
suspend fun refreshToken(clientId: String, nonce: String?, refreshToken: String, keyPair: DpopKeyPair? = null): OAuthToken

Refresh an access token using the provided OAuth client, nonce, and refresh token.

suspend fun refreshToken(oauthClient: OAuthClient, nonce: String?, refreshToken: String, keyPair: DpopKeyPair? = null): OAuthToken
Link copied to clipboard
suspend fun requestToken(oauthClient: OAuthClient, nonce: String, codeVerifier: String, code: String, keyPair: DpopKeyPair? = null): OAuthToken

Request an access token using the provided OAuth client, nonce, code verifier, and authorization code.

Link copied to clipboard
suspend fun revokeToken(oauthToken: OAuthToken)

Revoke the provided oauthToken using the OAuth server's revocation endpoint.

suspend fun revokeToken(accessToken: String, clientId: String, nonce: String?, keyPair: DpopKeyPair?)

Revoke the provided access token using the OAuth server's revocation endpoint.