OAuth flow
Drive the OAuth dance from the plugin detail page.
For oauth_2 plugins, the Plugins detail page shows an OAuth flow panel below the credentials panel.
Prerequisites
Before clicking Start OAuth:
- Set
client_idin the integration credentials - Set
client_secretin the integration credentials - Make sure the plugin is in Studio's OAuth registry (
studio-oauth.ts)
The Studio registry covers: slack, gmail, google-calendar, hubspot, github, notion, linear, asana. To add another, append a config to OAUTH_REGISTRY.
Flow
- Click Start OAuth —
POST /api/auth/startgenerates the auth URL with a signed state nonce - The auth URL opens in a new browser tab
- You complete the OAuth dance with the provider
- Provider redirects to
GET /api/auth/callback?code=...&state=... - Callback verifies state, calls
exchangeCodeForTokens, writes the tokens to the KeyStore - Redirects to
/studio/plugins/<id>?auth=success
A success banner appears at the top of the detail page. The newly-written access_token / refresh_token / expires_at / scope show up in the credentials panel (masked).
Why localhost-redirect, not ephemeral-listener
An ephemeral local-HTTP-listener model would work for CLI flows, but Studio doesn't need that — the dev server is already a long-running HTTP server the browser can reach on localhost:4317. The redirect target is just /api/auth/callback on Studio itself. Simpler, fewer moving parts.
Notes
State signing uses HMAC-SHA256 with STUDIO_OAUTH_STATE_SECRET (defaults to a dev value — set in prod). Pending sessions live in memory with a 10-minute TTL and one-shot consumption.