An OAuth2 JWT access token issued by Banking Circle's authorization endpoint, with the metadata needed to decide when to refresh it.
Banking Circle tokens are short-lived (documented as 5 minutes). The
guidance from Banking Circle is explicit: do not fetch a fresh token
on every request — only refresh once the current token has actually
expired (or is about to). expiring_soon?/2 implements that with a
configurable safety margin.
Summary
Functions
True if the token has already expired, or expires within margin_ms.
Builds a token from an authorization response body.
Types
@type t() :: %BankingCircle.Auth.Token{ expires_at: DateTime.t(), issued_at: DateTime.t(), value: String.t() }
Functions
@spec expiring_soon?(t(), non_neg_integer()) :: boolean()
True if the token has already expired, or expires within margin_ms.
Builds a token from an authorization response body.
Accepts either expires_in (seconds, relative) or an explicit
expires_at/expiresOn field, to be resilient to minor response
variations across environments.