glow_auth/access_token
An access token is just a string, but it typically expires.
Depending on the type of grant, it may be refreshable via a separate refresh token, or by directly requesting a new access token.
…the intention is to generate this from the response given when sending a token request.
Types
Represents a token returned from an oauth2 provider
Note: expires_in is seconds till expiry from time of issue which is converted to expires_at by adding to time_now().
pub type AccessToken {
AccessToken(
access_token: String,
token_type: String,
refresh_token: Option(String),
expires_at: Option(Int),
scope: Option(String),
)
}
Constructors
-
AccessToken( access_token: String, token_type: String, refresh_token: Option(String), expires_at: Option(Int), scope: Option(String), )
Functions
pub fn decode_token_from_response(
response: String,
) -> Result(AccessToken, DecodeError)
pub fn decoder() -> fn(Dynamic) ->
Result(AccessToken, List(DecodeError))
Decode an access token TODO: Any other params are possible, so should be returned as a map.
pub fn from_decoded_response(
access_token: String,
token_type: String,
refresh_token: Option(String),
expires_in: Option(Int),
scope: Option(String),
) -> AccessToken
pub fn has_an_expiry(access_token: AccessToken) -> Bool
pub fn is_expired(access_token: AccessToken) -> Bool
pub fn is_expired_at(access_token: AccessToken, at: Int) -> Bool
pub fn new(token: String) -> AccessToken
Returns a new AccessToken
given the access token string
.
pub fn normalize_token_type(token_type: String) -> String