Expand description
Token exchange, refresh, and what a token response has to prove.
The validation here is stricter than “did it parse”, because several fields are load-bearing in ways that fail silently if waved through:
token_typemust be exactlyDPoP. AcceptingBearerdiscards the proof-of-possession binding — the only thing making a stolen access token useless.scopemust containatproto, and the granted scope is what gets stored. Recording the requested scope instead means a narrowed grant is discovered as a mystery failure much later.submust be a well-formed atproto DID before it becomes a database key.id_tokenmust be absent — its presence means the server thinks it is doing OIDC, and nothing good follows from proceeding.expires_inis optional; a missing one means no proactive refresh, not a fabricated expiry.
Structs§
- Token
Response - A validated token response.
Enums§
- Refresh
Failure - What a failed refresh means for the stored session.
Constants§
- MIN_
REFRESH_ MARGIN_ SECS - Refresh at least this far ahead of expiry.
- REFRESH_
JITTER_ SECS - Extra, randomized margin on top of
MIN_REFRESH_MARGIN_SECS.
Functions§
- classify_
refresh_ failure - Classify a failed refresh.
- is_
stale - Whether a session should be refreshed now.
- is_
stale_ with_ margin - Whether a session should be refreshed now, against an explicit margin.
- parse_
token_ response - Validate a token response before anything is stored or sent.
- refresh_
margin - A jittered refresh margin.
- refresh_
request_ params - Form parameters for a refresh.
- token_
request_ params - Form parameters for the authorization-code exchange.