CPub.Web.Authorization.Token (CPub v0.3.0) View Source

An OAuth 2.0 Token that can be used to access ressources.

Link to this section Summary

Functions

Creates a new (initial) token for an Authorization.

Returns true if the Token is expired and can no longer be used to access a ressource.

Get token by access token.

Creates a refreshed token for an Authorization.

Returns the numer of seconds the Token is valid for after creation.

Link to this section Types

Specs

t() :: %CPub.Web.Authorization.Token{
  __meta__: term(),
  access_token: String.t(),
  authorization: String.t(),
  created_at: NaiveDateTime.t(),
  id: String.t()
}

Link to this section Functions

Specs

create(CPub.Web.Authorization.t()) :: {:ok, t()} | {:error, any()}

Creates a new (initial) token for an Authorization.

Specs

expired?(t()) :: bool()

Returns true if the Token is expired and can no longer be used to access a ressource.

Specs

get(String.t()) :: {:ok, t()} | {:error, any()}

Get token by access token.

Specs

refresh(CPub.Web.Authorization.t()) :: {:ok, t()} | {:error, any()}

Creates a refreshed token for an Authorization.

Specs

valid_for() :: non_neg_integer()

Returns the numer of seconds the Token is valid for after creation.