glow_auth/token_request
Token Request functions.
Types
Confidential clients or other clients issued client credentials can authenticate with the authorization server by means of auth header or the request body.
pub type AuthScheme {
AuthHeader
RequestBody
}
Constructors
-
AuthHeader
Clients in possession of a client password MAY use the HTTP Basic authentication scheme as defined in [RFC2617] to authenticate with the authorization server. The client identifier is encoded using the “application/x-www-form-urlencoded” encoding.
-
RequestBody
Alternatively, the authorization server MAY support including the client credentials in the request-body (client_id and client_secret).
The Access Token Scope is a list of unordered, space-deliminated, case-sensitive strings.
pub type Scope {
ScopeList(List(String))
ScopeString(String)
DefaultScope
}
Constructors
-
ScopeList(List(String))
Respresents the access token scope as a list of individual scope values that can later be joined into a space-delimited string.
-
ScopeString(String)
Represents the access token scope as a string of one or more space-deliminated scopes. Useful for a single scope or when the scopes have been pre-joined.
-
DefaultScope
Represents the omission of an access token scope. Useful when the authorization server will fall back to a default scope when the scope is not present in the body.
Functions
pub fn add_auth(
rb: TokenRequestBuilder(a),
client: Client(b),
auth_scheme: AuthScheme,
) -> TokenRequestBuilder(a)
Add auth by means of either AuthHeader or RequestBody
pub fn add_auth_to_body(
client: Client(a),
rb: TokenRequestBuilder(b),
) -> TokenRequestBuilder(b)
Add the client id and secret params to the token TokenRequestBuilder
Use this when posting the auth in the request body.
pub fn add_basic_auth_header(
request: Request(a),
auth_token: String,
) -> Request(a)
Add base64 encoded authorization
header for basic auth.
Use this when sending the auth in the request headers.
pub fn add_client_basic_auth_header(
client: Client(a),
request: Request(b),
) -> Request(b)
pub fn add_scope(
rb: TokenRequestBuilder(a),
scope: Scope,
) -> TokenRequestBuilder(a)
Add a scope to the builder if not a DefaultScope.
pub fn authorization_code(
client: Client(a),
token_uri: UriAppendage,
code: String,
redirect_uri: Uri,
) -> Request(String)
Build a token request using a code in Authorization Code grant.
Note that the redirect_uri must be identical to usage in the Authorization Uri.
pub fn client_credentials(
client: Client(a),
token_uri: UriAppendage,
auth_scheme: AuthScheme,
scope: Scope,
) -> Request(String)
Build a token request using the client id/secret and optionally a access token scope in Client Credentials grant
pub fn refresh(
client: Client(a),
token_uri: UriAppendage,
refresh_token: String,
) -> Request(String)
Build a token request using a Refresh token