An OAuth2 token pair as returned by Exact Online.
Access tokens are valid for ten minutes. Refresh tokens are valid for thirty
days and rotate on every use: each refresh returns a new refresh token and
invalidates the old one. Always persist the token returned by
Exact.OAuth.refresh/2 or the grant is lost and the user has to authorize
again.
Summary
Functions
Returns true when the token expires within skew seconds.
Builds a token from a decoded /api/oauth2/token response body.
Types
@type t() :: %Exact.Token{ access_token: String.t(), division: integer() | nil, expires_at: DateTime.t() | nil, refresh_token: String.t() | nil, token_type: String.t() }
Functions
@spec expired?(t(), non_neg_integer()) :: boolean()
Returns true when the token expires within skew seconds.
A token without an :expires_at is never considered expired, which is what
you want for a manually supplied access token.
@spec from_response(map(), DateTime.t()) :: t()
Builds a token from a decoded /api/oauth2/token response body.
expires_in is returned as a string by Exact Online and is accepted as
either a string or an integer here.