You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 12, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 12, 2026. It is now read-only.
Support multiple authentication flows for enterprise SSO compatibility #1
I can successfully sign in to GitHub Copilot in VSCode using enterprise SSO, but cannot sign in to opencode using the device code flow. The current implementation only supports a single authentication method, which fails for certain enterprise configurations.
Current Implementation
opencode-github-copilot currently only implements the device code flow (/login/device/code), which may not work for:
Enterprise SSO configurations
Self-hosted GitHub Enterprise Server (GHES) instances
Environments where device code flow is blocked or unsupported
Web worker contexts (CORS issues)
Proposed Solution
Implement multiple authentication flows with automatic fallback, matching VSCode's production implementation:
1. OAuth Authorization Code Flow with Local Server
Opens a local loopback server to handle OAuth redirects
Endpoint: /login/oauth/authorize
Best for: Desktop environments with enterprise SSO
Supports: PKCE for enhanced security
2. OAuth Authorization Code Flow with URI Handler
Uses vscode:// URI handler for redirects
Endpoint: /login/oauth/authorize
Best for: Web and remote environments
Supports: Enterprise SSO, PKCE
3. Device Code Flow (current)
Keep existing implementation as fallback
Endpoint: /login/device/code
Best for: Headless/remote environments
4. Personal Access Token (PAT) Flow
Manual token entry as last resort
Endpoint: /settings/tokens/new
Best for: All environments including old GHES versions
Technical Details
VSCode's implementation (in extensions/github-authentication/src/flows.ts) includes:
Flow Selection Logic:
// Intelligently selects flows based on:-Extensionhosttype(local/remote/webworker)-GitHubtarget(GitHub.com/EnterpriseServer/HostedEnterprise)-Clientcapabilitiesandconfiguration-Userpreferences
Security Features:
PKCE (Proof Key for Code Exchange) for OAuth flows
Secure token storage via system keychain
Proper state/nonce validation
Error Handling:
Automatic fallback to next available flow
Network error recovery
User cancellation handling
Timeout management (5min for device code)
Benefits
Broader Compatibility: Works with enterprise SSO, GHES, and restricted environments
Activity
huchenlei commentedon Dec 17, 2025
Closing. Wrong repo.
https://github.com/sst/opencode-copilot-auth/blob/main/index.mjs