Boruta.Oauth.Token (Boruta core v0.2.1) View Source

Token schema. Representing both access tokens and codes.

Link to this section Summary

Functions

Determines if a token is expired

Link to this section Types

Specs

t() :: %Boruta.Oauth.Token{
  client: Boruta.Oauth.Client.t(),
  expires_at: integer(),
  id: term(),
  inserted_at: DateTime.t(),
  redirect_uri: String.t(),
  refresh_token: String.t(),
  resource_owner: struct(),
  revoked_at: DateTime.t(),
  scope: String.t(),
  state: String.t(),
  type: String.t(),
  value: String.t()
}

Link to this section Functions

Specs

expired?(%Boruta.Oauth.Token{
  client: term(),
  expires_at: integer(),
  id: term(),
  inserted_at: term(),
  redirect_uri: term(),
  refresh_token: term(),
  resource_owner: term(),
  revoked_at: term(),
  scope: term(),
  state: term(),
  type: term(),
  value: term()
}) :: :ok | {:error, String.t()}

Determines if a token is expired

Examples

iex> expired?(%Boruta.Oauth.Token{expires_at: 1638316800}) # 1st january 2021
:ok

iex> expired?(%Boruta.Oauth.Token{expires_at: 0}) # 1st january 1970
{:error, "Token expired."}