The tokens one owner holds for one MCP server.
Besides the token response itself, a token records what refreshing it needs:
the authorization server's issuer and token_endpoint, the client_id it
was issued to, and the resource it is bound to.
scope is the granted scope, space-separated. When the token response omits
it, it is the scope that was requested.
Summary
Types
@type t() :: %AshAi.Mcp.OAuth.Token{ access_token: String.t(), client_id: String.t(), expires_at: DateTime.t() | nil, issuer: String.t(), obtained_at: DateTime.t() | nil, refresh_token: String.t() | nil, resource: String.t(), scope: String.t() | nil, server_url: String.t(), token_endpoint: String.t(), token_type: String.t() }
Functions
@spec fresh?(t(), non_neg_integer()) :: boolean()
Whether the access token is still usable skew seconds from now.
A token without an expiry is assumed usable until the server rejects it.
Builds a token from a map produced by to_map/1.
Converts the token to a JSON-safe map with string keys.