flwr_oauth2/response

Types

This type is returned by this module for a parsed access token response.

pub type AccessTokenResponse {
  AccessTokenResponse(
    access_token: String,
    token_type: String,
    expires_in: option.Option(Int),
    refresh_token: option.Option(String),
    scope: List(String),
  )
}

Constructors

  • AccessTokenResponse(
      access_token: String,
      token_type: String,
      expires_in: option.Option(Int),
      refresh_token: option.Option(String),
      scope: List(String),
    )

    If the access token request was successful a AccessTokenResponse is returned. it contains the access token, its type, the time when it will expire, a refresh token if present, and the final scope.

pub type AuthorizationServerError {
  AuthorizationServerError(
    status: Int,
    error: String,
    error_description: option.Option(String),
    error_uri: option.Option(String),
  )
}

Constructors

  • AuthorizationServerError(
      status: Int,
      error: String,
      error_description: option.Option(String),
      error_uri: option.Option(String),
    )

    If the response contains errors a ErrorResponse will be returned. It contains the HTTP status, the error code string, optionally an error description and an error URI.

Errors returned by this module when parsing responses, such as token responses from the OAuth 2.0 server.

pub type ResponseError {
  ErrorResponse(AuthorizationServerError)
  ParseError(common.ParseError)
}

Constructors

  • ErrorResponse(AuthorizationServerError)

    Constructor if the response is a semantic error, such as an unauthorized refresh token.

  • ParseError(common.ParseError)

    Constructor if the error is a syntactic one, such as an invalid content type or invalid json.

Values

pub fn parse_error_response(
  response: response.Response(String),
) -> Result(AuthorizationServerError, common.ParseError)

Parses an OAuth 2.0 error response defined in RFC6749 Error Response.

pub fn parse_token_response(
  response: response.Response(String),
) -> Result(AccessTokenResponse, ResponseError)

Parses a token response and returns the access and refresh token if valid response, otherwise the error response.

pub fn to_string(resp: AccessTokenResponse) -> String

Creates a String representation of a token request

✨ Search Document