BearerAuthProvider

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

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.

Constructors

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

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
fun clearToken()
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

Properties

Link copied to clipboard
open override val sendWithoutRequest: Boolean

Waits for HttpStatusCode.Unauthorized to send credentials.