auth.flow.started
Emitted when an OAuth flow begins.Provider name:
"openai" or "antigravity"Flow type:
"browser" (OAuth redirect) or "device_code" (headless)auth.flow.url
Emitted when a browser URL is ready for the user to open.Full OAuth authorization URL. Your client must display this URL to the user.
ISO 8601 timestamp when the URL expires (typically 5 minutes)
auth.flow.device_code
Emitted for device code OAuth flows (headless/CI environments).Short code the user must enter on the verification URL
URL where the user enters the device code
Seconds until the device code expires (typically 900 = 15 minutes)
Device code flow example
auth.flow.completed
Emitted when OAuth succeeds and credentials are stored.User profile information from the provider (when available)
auth.flow.failed
Emitted when OAuth fails.Human-readable error message
Error code:
"user_canceled", "timeout", "network_error", etc.state.changed
Emitted when global authentication state changes (provider added/removed).Type of change:
"auth_updated", "model_changed", "config_changed"List of currently authenticated provider names
OAuth flow sequences
Browser flow (desktop)
auth.flow.started- Flow beginsauth.flow.url- URL available- User opens URL in browser and approves
auth.flow.completed- Successstate.changed- Auth state updated
Device code flow (headless)
auth.flow.started- Flow begins withflow_type: "device_code"auth.flow.device_code- Device code available- User visits verification URL and enters code
- loaf polls for completion (no intermediate events)
auth.flow.completed- Successstate.changed- Auth state updated
Failure flow
auth.flow.started- Flow beginsauth.flow.urlorauth.flow.device_code- Auth details provided- User cancels or timeout occurs
auth.flow.failed- Failure event
Handling timeouts
Browser URLs expire after 5 minutes. Device codes expire after 15 minutes. If the user doesn’t complete authentication in time, you’ll receiveauth.flow.failed with code: "timeout".
API key authentication
API key setup (OpenRouter, Exa) does not emit events—use the synchronousauth.set.openrouter_key and auth.set.exa_key methods instead.
Related
- Event system overview - Event format and categories
- Auth methods - Authentication RPC methods
- RPC authentication - OAuth in RPC mode