Overview
SwitchAILocal supports multiple authentication methods for different AI providers. Login commands handle OAuth flows, API key configuration, and service account imports.Gemini / Google
OAuth Login
Initiates Google OAuth login for Gemini API access. Opens browser for authentication unless
--no-browser is specified.Google Cloud Project ID. Not required for standard Gemini API but needed for Vertex AI.
Don’t automatically open browser. Displays URL for manual authentication.
Vertex AI Import
Path to Google Cloud service account JSON key file for Vertex AI authentication.
The service account must have the following roles:
roles/aiplatform.userfor Vertex AI accessroles/ml.developerfor model access
Claude / Anthropic
Authenticate with Claude using OAuth flow. Opens browser for Anthropic account login.
Codex
Authenticate with OpenAI Codex using OAuth.
Qwen
Authenticate with Alibaba Qwen AI using OAuth.
Antigravity
Authenticate with Antigravity AI platform using OAuth.
Ollama (Local)
Connect to local Ollama instance. No authentication required, but verifies connectivity.
Vibe (Local)
Connect to local Vibe AI instance.
iFlow
OAuth Login
Authenticate with iFlow using OAuth.
Cookie Authentication
Authenticate with iFlow using browser cookies. Useful when OAuth is not available.
Common Flags
All login commands support the following optional flags:Disable automatic browser opening. Instead, display the OAuth URL in the terminal for manual authentication.Useful for:
- Headless servers / SSH sessions
- CI/CD environments
- Security policies preventing browser automation
Authentication Storage
Credentials are stored in the auth directory defined in your config:Security Best Practices
Security Best Practices
- File Permissions: Auth files are automatically created with
0600permissions (owner read/write only) - Token Encryption: Sensitive tokens are encrypted at rest
- Token Rotation: OAuth tokens are automatically refreshed when expired
- Centralized Storage: Use PostgreSQL, Git, or Object Store backends for team deployments
Verifying Authentication
After logging in, verify your authentication status:Troubleshooting
OAuth Callback Failed
OAuth Callback Failed
If the OAuth callback fails:
- Ensure no other service is using the callback port (usually 8765)
- Check firewall settings allow localhost connections
- Try
--no-browserand manually complete authentication
Credentials Not Persisting
Credentials Not Persisting
Check auth directory permissions and storage backend:
Token Expired
Token Expired
OAuth tokens are refreshed automatically, but you can re-authenticate:
Related Commands
- Server Command - Start the proxy server
- Heartbeat Commands - Verify provider connectivity