Architecture: How to implement OAuth authentication for a VSCode extension...
Documentation for Sessions
🏗️ Architecture: How to implement OAuth authentication for a VSCode extension...
Date: 2026-02-05
Time: 04:38:46 UTC
Session: editor2-89.6
Agent: backend
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
How to implement OAuth authentication for a VSCode extension that connects to a web backend?
Task: VSCode Extension OAuth Authentication Flow
🎯 Decision Made
Chosen:
Open browser with localhost callback server
Options Considered:
- Redirect to browser with custom protocol handler (mcp://)
- Open browser with localhost callback server
- Use VSCode's built-in authentication provider API
- Manual token entry only
💭 Reasoning
VSCode extensions can start a local HTTP server to receive OAuth callbacks. The flow: 1) Extension generates random state for CSRF protection, 2) Finds available port and starts temp HTTP server, 3) Opens browser to backend /auth/mcp/authorize with redirect_uri=http://localhost:{port}/auth/callback, 4) Backend redirects to frontend auth page, 5) User authorizes, 6) Frontend calls backend POST /auth/mcp/callback, 7) Backend returns token, 8) Frontend redirects to extension's localhost server with token, 9) Extension saves token and closes server. This approach works cross-platform and doesn't require custom protocol handlers.
📁 Files Involved
apps/vscode-gograb-ai/src/panels/main-panel.tsapis/backend-api/src/app/auth/mcp-oauth.controller.tsapps/gograb-space/src/app/auth/mcp-auth/mcp-auth.component.ts
🔗 Related
- Decision ID:
dev_1770266326637_r97zt9e - Session: 89
- Workspace: editor2
Auto-generated by MCP Smart Consolidation