Skip to main content
For providers that use OAuth2 (Spotify, QuickBooks, Xero, Reddit, etc.), the initial consent and code exchange happen outside the broker boundary. aivault only handles the refresh/runtime phase.

oauth setup

Generate a consent URL for an OAuth2 provider.
This returns a consent URL — open it in a browser to authorize the application.

Options

Full OAuth2 lifecycle

The key insight: aivault manages the runtime token refresh automatically. You only need to do the initial consent/exchange once. After that, the broker handles refreshing expired tokens transparently on every invoke. For public/native OAuth clients that use PKCE, omit clientSecret from the secret JSON:
--value-file is preferred for token payloads because the secret value does not appear in the process argument list.

ChatGPT account refresh and recovery

For CODEX_OAUTH_JSON, aivault refreshes only the account selected for the requested capability. An unusable ChatGPT account does not prevent another account, API key, or unrelated provider from making requests. Listing credentials does not refresh tokens; a listed account may still need to reconnect. The native access lease and broker share a per-account process lock, reread the stored token after acquiring it, and persist rotated tokens before returning. Secret-record updates also use a process lock so usage timestamps cannot overwrite new credentials. A reconnect completed during refresh takes precedence over the older refresh result. An upstream API 401 triggers one refresh and one retry, including streamed calls. Permanent token failures (refresh_token_expired, refresh_token_reused, refresh_token_invalidated, invalid_refresh_token, invalid_grant, or an unclassified token-endpoint 401) report a safe code and ask you to reconnect that account. The failure is cached in its encrypted credential until reconnection replaces it. Temporary failures remain retryable. Raw token error bodies are never included in these diagnostics. In Moldable, reconnect the affected account from the ChatGPT provider settings. Reconnecting replaces its tokens and clears the cached refresh failure. Next: Security