Boruta core v0.1.0-rc.4 Boruta.Oauth.Token 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

Link to this type

t()

View Source
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(),
  scope: String.t(),
  state: String.t(),
  type: String.t(),
  value: String.t()
}

Link to this section Functions

Link to this function

expired?(token)

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

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."}