glow_auth/authorize_uri

AuthorizeUri provides a builder to generate your Authorization Uri to use in an Authorization Code or Implicit grant flow.

Since this is a redirection-based flow, the client must be capable of interacting with the resource owner’s user-agent (typically a web browser) and capable of receiving incoming requests (via redirection) from the authorization server.

Basically, send your user to the Authorization Uri, where it’s expected they will login or authenticate somehow, then they get redirected back.

In Authorization Code flow, they’ll be redirected with a “code” in the uri, which is short lived (10 minutes expiry recommended) that must be exchanged for an Access Token separately.

In Implicit flow, they’ll be redirected with a access token details directly encoded in the uri.

In both cases, you can send over a state which will be sent back to you on the redirect.

Failure is represented by the fields:

The exception is if there is a problem with the Redirect Uri, like not set, or not registered in the Authorization provider, in which case the redirect back will just not occur.

Types

Represents the details needed to build an authorization Uri.

Use build, set_scope, set_state to build up one of these, then to_uri to convert to a Uri.

pub type AuthUriSpec(body) {
  AuthUriSpec(
    client: Client(body),
    authorize_uri: UriAppendage,
    redirect_uri: Uri,
    scope: Option(String),
    state: Option(String),
  )
}

Constructors

  • AuthUriSpec(
      client: Client(body),
      authorize_uri: UriAppendage,
      redirect_uri: Uri,
      scope: Option(String),
      state: Option(String),
    )

Functions

pub fn build(client: Client(a), authorize_uri: UriAppendage, redirect_uri: Uri) -> AuthUriSpec(
  a,
)

Build a AuthUriSpec for an AuthCode authorize_uri.

Important things to note:

  • The exact redirect_uri specified in this uri must also be provided when requesting an access token.
pub fn set_redirect_uri(spec: AuthUriSpec(a), redirect_uri: Uri) -> AuthUriSpec(
  a,
)

Set the Redirect uri in the AuthUriSpec

pub fn set_scope(spec: AuthUriSpec(a), scope: String) -> AuthUriSpec(
  a,
)

Set the scope in the AuthUriSpec

pub fn set_state(spec: AuthUriSpec(a), state: String) -> AuthUriSpec(
  a,
)

Set the state in the AuthUriSpec

pub fn to_uri(spec: AuthUriSpec(a)) -> Uri

Convert an AuthUriSpec to an Authorization Uri.