Install the release candidate
next tag tracks the current prerelease.
Read a profile
currentAccessToken is your application function. If you use Better Auth, obtain it through Better Auth’s token API. Keep one token owner. Constructing the resource client performs no compulsory account preflight.
Choose an account
Create a discovery client with the same token getter and no account selector. Iterate every page, then save the user’s explicit account choice under your customer and client registration:Store customer tokens
For an app without an auth framework,OFAuthLink provides standard URL, PKCE, callback parsing, exchange, refresh, and revocation helpers:
attempt.state and attempt.codeVerifier with the current trusted application user, browser session, expiry, and registration version before redirecting to attempt.url.
On return, verify and atomically consume the matching pending record. A foreign session must not consume it. Then parse and exchange:
expires_in. Refresh near expiry with link.refresh({ refreshToken }). The returned refresh token stays the same, so concurrent refresh and retry after a lost response require no distributed lock or attempt journal. Retain conditional writes when the user changes or disconnects a registration.
The Express OAuth example shows PostgreSQL persistence, session-bound callbacks, account discovery and selection, targeted provider reconnect, and revocation. Its database stores ordinary application state, not an SDK-specific refresh protocol.
Handle failures
API failures throwOFAuthAPIError. Read code, recoveryAction, and requestId. Follow Handle failed requests.
An invalid refresh grant requires authorization again. Transient refresh failures can be retried. A provider reconnect error needs targeted reconnect; OAuth refresh cannot repair it. Never repeat an interrupted message, post, or story automatically.