OpenPayments.Types.AccessToken (open_payments_elixir v1.0.0)

Copy Markdown View Source

An issued resource access token returned by an authorization server.

The pinned schema requires an opaque string value, an absolute-URI manage endpoint and an ordered typed access list. Optional expires_in is an integer; omission becomes nil and explicit JSON null is rejected. The schema declares no minimum or maximum for expiry integers. Additional object fields are forbidden.

Values, management URI spelling and expiry metadata are preserved. This type checks response data without imposing the request header's token68 alphabet or HTTP target policy. It does not track elapsed time, issue management requests, rotate tokens or compare access to a grant request.

Inspection exposes only expiry metadata. Explicit to_map/1 and JSON encoding contain the token and any nested card payloads. Errors retain safe field paths. Validate manually constructed or modified structs with validate/1; to_map/1 converts shape without validating it.

Summary

Functions

Decodes an issued token and its typed access entries.

Converts to protocol fields, including token/card values, without validating.

Validates issued token fields and revalidates all typed access entries.

Types

t()

@type t() :: %OpenPayments.Types.AccessToken{
  access: OpenPayments.Types.Access.t(),
  expires_in: integer() | nil,
  manage: String.t(),
  value: String.t()
}

Functions

from_map(data)

@spec from_map(map()) :: {:ok, t()} | {:error, OpenPayments.Error.t()}

Decodes an issued token and its typed access entries.

to_map(token)

@spec to_map(t()) :: map()

Converts to protocol fields, including token/card values, without validating.

validate(token)

@spec validate(t()) :: :ok | {:error, OpenPayments.Error.t()}

Validates issued token fields and revalidates all typed access entries.