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:


pub type TokenRequestBuilder(body) {
  TokenRequestBuilder(request: Request(body), params: Params)


  • TokenRequestBuilder(request: Request(body), params: Params)


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.

Search Document