glow_auth/token_request_builder
Request Builder to help building up token requests.
It’s basically just a Request with additional Params to form-encode in the body, or (less commonly) use as the query part of the Uri.
Token request requirements:
- MAY have query component
- MUST NOT have fragment component
- MUST use TLS
- MUST be “POST”
- Params without value MUST be same as omission
- No repeat params
scope
space-delimited case insensitive strings defined by auth server- MAY full or partly ignore
- If different, MUST include
scope
in response - A default must be defined
Types
pub type TokenRequestBuilder(body) {
TokenRequestBuilder(request: Request(body), params: Params)
}
Constructors
-
TokenRequestBuilder(request: Request(body), params: Params)
Functions
pub fn from_request(
request: Request(a),
) -> TokenRequestBuilder(a)
Constructor: from request
pub fn from_uri(uri: Uri) -> TokenRequestBuilder(String)
Convert a Uri to a TokenRequestBuilder
Note that Request requires a schema and host, but uri doesn’t, so here:
- If you don’t specify a scheme,
https
is assumed - If you don’t specify a host,
localhost
is assumed
pub fn map_request(
rb: TokenRequestBuilder(a),
f: fn(Request(a)) -> Request(b),
) -> TokenRequestBuilder(b)
Map f
over the request.
pub fn put_param(
rb: TokenRequestBuilder(a),
key: String,
value: String,
) -> TokenRequestBuilder(a)
Put one param in
pub fn set_params(
rb: TokenRequestBuilder(a),
params: Params,
) -> TokenRequestBuilder(a)
Set all the Params
pub fn to_token_request(
rb: TokenRequestBuilder(a),
) -> Request(String)
Access Tokens are requested by form encoded values in the body, while the server returns json.
Some flows allow a GET request where the request query-encodes into the uri.
This function handles both depending on the request.method.