StoredToken

A persisted OAuth token set for a single resource (MCP server). expiresAt is an absolute Unix timestamp (seconds) at which the access token expires; 0 means "no known expiry" (treated as never auto-refreshed on a timer).

@safe
struct StoredToken {
string accessToken;
string tokenType;
long expiresAt;
string refreshToken;
string scope_;
string resource;
}

Members

Functions

hasToken
bool hasToken()

Whether this record holds a usable access token.

Static functions

fromTokenSet
StoredToken fromTokenSet(TokenSet ts, string resource, long now, string prevRefresh)

Build a StoredToken from a freshly issued TokenSet, computing the absolute expiry from now + expiresIn (only when expiresIn is positive). A TokenSet from a refresh that omits refresh_token keeps prevRefresh (RFC 6749 allows the AS to reissue or retain it).

Variables

clientId
string clientId;

The OAuth client_id used to obtain this token (pre-registered, CIMD, or DCR-issued). Persisted so a later refresh can authenticate at the token endpoint even when no client_id was statically configured.