OAuth2 v2.0.0 OAuth2.AccessToken View Source
This module defines the OAuth2.AccessToken
struct and provides functionality
to make authorized requests to an OAuth2 provider using the AccessToken
returned by the provider.
The OAuth2.AccessToken
struct is created for you when you use the
OAuth2.Client.get_token
Link to this section Summary
Functions
Determines if the access token has expired.
Determines if the access token will expire or not.
Returns a unix timestamp based on now + expires_at (in seconds).
Returns a new OAuth2.AccessToken
struct given the access token string
or a response map
.
Link to this section Types
access_token()
View Source
access_token() :: binary()
access_token() :: binary()
body() View Source
expires_at()
View Source
expires_at() :: integer()
expires_at() :: integer()
other_params() View Source
refresh_token()
View Source
refresh_token() :: binary() | nil
refresh_token() :: binary() | nil
t()
View Source
t() :: %OAuth2.AccessToken{
access_token: access_token(),
expires_at: expires_at(),
other_params: other_params(),
refresh_token: refresh_token(),
token_type: token_type()
}
t() :: %OAuth2.AccessToken{ access_token: access_token(), expires_at: expires_at(), other_params: other_params(), refresh_token: refresh_token(), token_type: token_type() }
token_type()
View Source
token_type() :: binary()
token_type() :: binary()
Link to this section Functions
expired?(token) View Source
Determines if the access token has expired.
expires?(token)
View Source
expires?(OAuth2.AccessToken.t()) :: boolean()
expires?(OAuth2.AccessToken.t()) :: boolean()
Determines if the access token will expire or not.
Returns true
unless expires_at
is nil
.
expires_at(val) View Source
Returns a unix timestamp based on now + expires_at (in seconds).
new(token) View Source
Returns a new OAuth2.AccessToken
struct given the access token string
or a response map
.
Note if giving a map, please be sure to make the key a string
no an atom
.
This is used by OAuth2.Client.get_token/4
to create the OAuth2.AccessToken
struct.
Example
iex> OAuth2.AccessToken.new("abc123")
%OAuth2.AccessToken{access_token: "abc123", expires_at: nil, other_params: %{}, refresh_token: nil, token_type: "Bearer"}
iex> OAuth2.AccessToken.new(%{"access_token" => "abc123"})
%OAuth2.AccessToken{access_token: "abc123", expires_at: nil, other_params: %{}, refresh_token: nil, token_type: "Bearer"}