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
AccessTokenResponseis returned. it contains the access token, its type, the time when it will expire, a refresh token if present, and the final scope.
Errors returned by this module when parsing responses, such as token responses from the OAuth 2.0 server.
pub type ResponseError {
ErrorResponse(
status: Int,
error: String,
error_description: option.Option(String),
error_uri: option.Option(String),
)
ParseError(error: json.DecodeError)
}
Constructors
-
ErrorResponse( status: Int, error: String, error_description: option.Option(String), error_uri: option.Option(String), )If the response contains errors a
ErrorResponsewill be returned. It contains the HTTP status, the error code string, optionally an error description and an error URI. -
ParseError(error: json.DecodeError)If the response does not contain valid JSON or does not conform to the error response format defined by RFC6749 Error Response this error will be returned.
Values
pub fn parse_error_response(
response: response.Response(String),
) -> ResponseError
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