BearerAuthProvider

class BearerAuthProvider(refreshTokens: suspend RefreshTokensParams.() -> BearerTokens?, loadTokens: suspend () -> BearerTokens?, sendWithoutRequestCallback: (HttpRequestBuilder) -> Boolean = { true }, realm: String?) : AuthProvider(source)

An authentication provider for the Bearer HTTP authentication scheme. Bearer authentication involves security tokens called bearer tokens. As an example, these tokens can be used as a part of OAuth flow to authorize users of your application by using external providers, such as Google, Facebook, Twitter, and so on.

You can learn more from Bearer authentication.

Report a problem

Constructors

Link copied to clipboard
constructor(refreshTokens: suspend RefreshTokensParams.() -> BearerTokens?, loadTokens: suspend () -> BearerTokens?, sendWithoutRequestCallback: (HttpRequestBuilder) -> Boolean = { true }, realm: String?)

Properties

Link copied to clipboard
open override val sendWithoutRequest: Boolean

Waits for HttpStatusCode.Unauthorized to send credentials.

Functions

Link copied to clipboard
open suspend override fun addRequestHeaders(request: HttpRequestBuilder, authHeader: HttpAuthHeader?)

Adds an authentication method headers and credentials.

Link copied to clipboard

Clears the currently stored authentication tokens from the cache.

Link copied to clipboard
open override fun isApplicable(auth: HttpAuthHeader): Boolean

Checks if current provider is applicable to the request.

Link copied to clipboard
open suspend override fun refreshToken(response: HttpResponse): Boolean

Refreshes a token if required.

Link copied to clipboard
open override fun sendWithoutRequest(request: HttpRequestBuilder): Boolean