Spaces:
Paused
docs(deployment): π add comprehensive VPS deployment guide for OAuth providers
Browse filesAdd detailed appendix section covering VPS deployment workflows for OAuth-based providers (Antigravity, Gemini CLI, iFlow). The guide addresses the localhost callback challenge inherent to OAuth flows on remote servers.
- Document three professional deployment approaches: local authentication with credential export (recommended), SSH port forwarding for direct VPS authentication, and credential file copying
- Provide production-ready security best practices including firewall configuration, environment variable management, and systemd service setup
- Include comprehensive troubleshooting section for common VPS deployment issues
- Add comparison tables for OAuth callback ports, credential storage methods, and deployment approach trade-offs
- Explain technical rationale for why OAuth callbacks fail on remote servers and how each solution addresses the problem
- Deployment guide.md +366 -0
|
@@ -174,3 +174,369 @@ curl -X POST https://your-service.onrender.com/v1/chat/completions -H "Content-T
|
|
| 174 |
|
| 175 |
That is it.
|
| 176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
That is it.
|
| 176 |
|
| 177 |
+
---
|
| 178 |
+
|
| 179 |
+
## Appendix: Deploying to a Custom VPS
|
| 180 |
+
|
| 181 |
+
If you're deploying the proxy to a **custom VPS** (DigitalOcean, AWS EC2, Linode, etc.) instead of Render.com, you'll encounter special considerations when setting up OAuth providers (Antigravity, Gemini CLI, iFlow). This section covers the professional deployment workflow.
|
| 182 |
+
|
| 183 |
+
### Understanding the OAuth Callback Problem
|
| 184 |
+
|
| 185 |
+
OAuth providers like Antigravity, Gemini CLI, and iFlow require an interactive authentication flow that:
|
| 186 |
+
|
| 187 |
+
1. Opens a browser for you to log in
|
| 188 |
+
2. Redirects back to a **local callback server** running on specific ports
|
| 189 |
+
3. Receives an authorization code to exchange for tokens
|
| 190 |
+
|
| 191 |
+
The callback servers bind to `localhost` on these ports:
|
| 192 |
+
|
| 193 |
+
| Provider | Port | Notes |
|
| 194 |
+
|---------------|-------|--------------------------------------------|
|
| 195 |
+
| **Antigravity** | 51121 | Google OAuth with extended scopes |
|
| 196 |
+
| **Gemini CLI** | 8085 | Google OAuth for Gemini API |
|
| 197 |
+
| **iFlow** | 11451 | Authorization Code flow with API key fetch |
|
| 198 |
+
| **Qwen Code** | N/A | Uses Device Code flow - works on remote VPS β
|
|
| 199 |
+
|
| 200 |
+
**The Issue**: When running on a remote VPS, your local browser cannot reach `http://localhost:51121` (or other callback ports) on the remote server, causing authentication to fail with a "connection refused" error.
|
| 201 |
+
|
| 202 |
+
### Recommended Deployment Workflow
|
| 203 |
+
|
| 204 |
+
There are **three professional approaches** to handle OAuth authentication for VPS deployment, listed from most recommended to least:
|
| 205 |
+
|
| 206 |
+
---
|
| 207 |
+
|
| 208 |
+
### **Option 1: Authenticate Locally, Deploy Credentials (RECOMMENDED)**
|
| 209 |
+
|
| 210 |
+
This is the **cleanest and most secure** approach. Complete OAuth flows on your local machine, export to environment variables, then deploy.
|
| 211 |
+
|
| 212 |
+
#### Step 1: Clone and Set Up Locally
|
| 213 |
+
|
| 214 |
+
```bash
|
| 215 |
+
# On your local development machine
|
| 216 |
+
git clone https://github.com/YOUR-USERNAME/LLM-API-Key-Proxy.git
|
| 217 |
+
cd LLM-API-Key-Proxy
|
| 218 |
+
|
| 219 |
+
# Install dependencies
|
| 220 |
+
pip install -r requirements.txt
|
| 221 |
+
```
|
| 222 |
+
|
| 223 |
+
#### Step 2: Run OAuth Authentication Locally
|
| 224 |
+
|
| 225 |
+
```bash
|
| 226 |
+
# Start the credential tool
|
| 227 |
+
python -m rotator_library.credential_tool
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
Select **"Add OAuth Credential"** and choose your provider:
|
| 231 |
+
- Antigravity
|
| 232 |
+
- Gemini CLI
|
| 233 |
+
- iFlow
|
| 234 |
+
- Qwen Code (works directly on VPS, but can authenticate locally too)
|
| 235 |
+
|
| 236 |
+
The tool will:
|
| 237 |
+
1. Open your browser automatically
|
| 238 |
+
2. Start a local callback server
|
| 239 |
+
3. Complete the OAuth flow
|
| 240 |
+
4. Save credentials to `oauth_creds/<provider>_oauth_N.json`
|
| 241 |
+
|
| 242 |
+
#### Step 3: Export Credentials to Environment Variables
|
| 243 |
+
|
| 244 |
+
Still in the credential tool, select the export option for each provider:
|
| 245 |
+
- **"Export Antigravity to .env"**
|
| 246 |
+
- **"Export Gemini CLI to .env"**
|
| 247 |
+
- **"Export iFlow to .env"**
|
| 248 |
+
- **"Export Qwen Code to .env"**
|
| 249 |
+
|
| 250 |
+
The tool generates a `.env` file snippet like:
|
| 251 |
+
|
| 252 |
+
```env
|
| 253 |
+
# Antigravity OAuth Credentials
|
| 254 |
+
ANTIGRAVITY_ACCESS_TOKEN="ya29.a0AfB_byD..."
|
| 255 |
+
ANTIGRAVITY_REFRESH_TOKEN="1//0gL6dK9..."
|
| 256 |
+
ANTIGRAVITY_EXPIRY_DATE="1735901234567"
|
| 257 |
+
ANTIGRAVITY_EMAIL="user@gmail.com"
|
| 258 |
+
ANTIGRAVITY_CLIENT_ID="1071006060591-..."
|
| 259 |
+
ANTIGRAVITY_CLIENT_SECRET="GOCSPX-..."
|
| 260 |
+
ANTIGRAVITY_TOKEN_URI="https://oauth2.googleapis.com/token"
|
| 261 |
+
ANTIGRAVITY_UNIVERSE_DOMAIN="googleapis.com"
|
| 262 |
+
```
|
| 263 |
+
|
| 264 |
+
Copy these variables to a file (e.g., `oauth_credentials.env`).
|
| 265 |
+
|
| 266 |
+
#### Step 4: Deploy to VPS
|
| 267 |
+
|
| 268 |
+
**Method A: Using Environment Variables (Recommended)**
|
| 269 |
+
|
| 270 |
+
```bash
|
| 271 |
+
# On your VPS
|
| 272 |
+
cd /path/to/LLM-API-Key-Proxy
|
| 273 |
+
|
| 274 |
+
# Create or edit .env file
|
| 275 |
+
nano .env
|
| 276 |
+
|
| 277 |
+
# Paste the exported environment variables
|
| 278 |
+
# Also add your PROXY_API_KEY and other provider keys
|
| 279 |
+
|
| 280 |
+
# Start the proxy
|
| 281 |
+
uvicorn src.proxy_app.main:app --host 0.0.0.0 --port 8000
|
| 282 |
+
```
|
| 283 |
+
|
| 284 |
+
**Method B: Upload Credential Files**
|
| 285 |
+
|
| 286 |
+
```bash
|
| 287 |
+
# On your local machine - copy credential files to VPS
|
| 288 |
+
scp -r oauth_creds/ user@your-vps-ip:/path/to/LLM-API-Key-Proxy/
|
| 289 |
+
|
| 290 |
+
# On VPS - verify files exist
|
| 291 |
+
ls -la oauth_creds/
|
| 292 |
+
|
| 293 |
+
# Start the proxy
|
| 294 |
+
uvicorn src.proxy_app.main:app --host 0.0.0.0 --port 8000
|
| 295 |
+
```
|
| 296 |
+
|
| 297 |
+
> **Note**: Environment variables are preferred for production deployments (more secure, easier to manage, works with container orchestration).
|
| 298 |
+
|
| 299 |
+
---
|
| 300 |
+
|
| 301 |
+
### **Option 2: SSH Port Forwarding (For Direct VPS Authentication)**
|
| 302 |
+
|
| 303 |
+
If you need to authenticate directly on the VPS (e.g., you don't have a local development environment), use SSH port forwarding to create secure tunnels.
|
| 304 |
+
|
| 305 |
+
#### How It Works
|
| 306 |
+
|
| 307 |
+
SSH tunnels forward ports from your local machine to the remote VPS, allowing your local browser to reach the callback servers.
|
| 308 |
+
|
| 309 |
+
#### Step-by-Step Process
|
| 310 |
+
|
| 311 |
+
**Step 1: Create SSH Tunnels**
|
| 312 |
+
|
| 313 |
+
From your **local machine**, open a terminal and run:
|
| 314 |
+
|
| 315 |
+
```bash
|
| 316 |
+
# Forward all OAuth callback ports at once
|
| 317 |
+
ssh -L 51121:localhost:51121 -L 8085:localhost:8085 -L 11451:localhost:11451 user@your-vps-ip
|
| 318 |
+
|
| 319 |
+
# Alternative: Forward ports individually as needed
|
| 320 |
+
ssh -L 51121:localhost:51121 user@your-vps-ip # For Antigravity
|
| 321 |
+
ssh -L 8085:localhost:8085 user@your-vps-ip # For Gemini CLI
|
| 322 |
+
ssh -L 11451:localhost:11451 user@your-vps-ip # For iFlow
|
| 323 |
+
```
|
| 324 |
+
|
| 325 |
+
**Keep this SSH session open** during the entire authentication process.
|
| 326 |
+
|
| 327 |
+
**Step 2: Run Credential Tool on VPS**
|
| 328 |
+
|
| 329 |
+
In the same SSH terminal (or open a new SSH connection):
|
| 330 |
+
|
| 331 |
+
```bash
|
| 332 |
+
cd /path/to/LLM-API-Key-Proxy
|
| 333 |
+
|
| 334 |
+
# Ensure Python dependencies are installed
|
| 335 |
+
pip install -r requirements.txt
|
| 336 |
+
|
| 337 |
+
# Run the credential tool
|
| 338 |
+
python -m rotator_library.credential_tool
|
| 339 |
+
```
|
| 340 |
+
|
| 341 |
+
**Step 3: Complete OAuth Flow**
|
| 342 |
+
|
| 343 |
+
1. Select **"Add OAuth Credential"** β Choose your provider
|
| 344 |
+
2. The tool displays an authorization URL
|
| 345 |
+
3. **Click the URL in your local browser** (works because of the SSH tunnel!)
|
| 346 |
+
4. Complete the authentication flow
|
| 347 |
+
5. The browser redirects to `localhost:<port>` - **this now routes through the tunnel to your VPS**
|
| 348 |
+
6. Credentials are saved to `oauth_creds/` on the VPS
|
| 349 |
+
|
| 350 |
+
**Step 4: Export to Environment Variables**
|
| 351 |
+
|
| 352 |
+
Still in the credential tool:
|
| 353 |
+
1. Select the export option for each provider
|
| 354 |
+
2. Copy the generated environment variables
|
| 355 |
+
3. Add them to `/path/to/LLM-API-Key-Proxy/.env` on your VPS
|
| 356 |
+
|
| 357 |
+
**Step 5: Close Tunnels and Deploy**
|
| 358 |
+
|
| 359 |
+
```bash
|
| 360 |
+
# Exit the SSH session with tunnels (Ctrl+D or type 'exit')
|
| 361 |
+
# Tunnels are no longer needed
|
| 362 |
+
|
| 363 |
+
# Start the proxy on VPS (in a screen/tmux session or as a service)
|
| 364 |
+
uvicorn src.proxy_app.main:app --host 0.0.0.0 --port 8000
|
| 365 |
+
```
|
| 366 |
+
|
| 367 |
+
---
|
| 368 |
+
|
| 369 |
+
### **Option 3: Copy Credential Files to VPS**
|
| 370 |
+
|
| 371 |
+
If you've already authenticated locally and have credential files, you can copy them directly.
|
| 372 |
+
|
| 373 |
+
#### Copy OAuth Credential Files
|
| 374 |
+
|
| 375 |
+
```bash
|
| 376 |
+
# From your local machine
|
| 377 |
+
scp -r oauth_creds/ user@your-vps-ip:/path/to/LLM-API-Key-Proxy/
|
| 378 |
+
|
| 379 |
+
# Verify on VPS
|
| 380 |
+
ssh user@your-vps-ip
|
| 381 |
+
ls -la /path/to/LLM-API-Key-Proxy/oauth_creds/
|
| 382 |
+
```
|
| 383 |
+
|
| 384 |
+
Expected files:
|
| 385 |
+
- `antigravity_oauth_1.json`
|
| 386 |
+
- `gemini_cli_oauth_1.json`
|
| 387 |
+
- `iflow_oauth_1.json`
|
| 388 |
+
- `qwen_code_oauth_1.json`
|
| 389 |
+
|
| 390 |
+
#### Configure .env to Use Credential Files
|
| 391 |
+
|
| 392 |
+
On your VPS, edit `.env`:
|
| 393 |
+
|
| 394 |
+
```env
|
| 395 |
+
# Option A: Use credential files directly (not recommended for production)
|
| 396 |
+
# No special configuration needed - the proxy auto-detects oauth_creds/ folder
|
| 397 |
+
|
| 398 |
+
# Option B: Export to environment variables (recommended)
|
| 399 |
+
# Run credential tool and export each provider to .env
|
| 400 |
+
```
|
| 401 |
+
|
| 402 |
+
---
|
| 403 |
+
|
| 404 |
+
### Environment Variables vs. Credential Files
|
| 405 |
+
|
| 406 |
+
| Aspect | Environment Variables | Credential Files |
|
| 407 |
+
|---------------------------|------------------------------------------|--------------------------------------------|
|
| 408 |
+
| **Security** | β
More secure (no files on disk) | β οΈ Files readable if server compromised |
|
| 409 |
+
| **Container-Friendly** | β
Perfect for Docker/K8s | β Requires volume mounts |
|
| 410 |
+
| **Ease of Rotation** | β
Update .env and restart | β οΈ Need to regenerate JSON files |
|
| 411 |
+
| **Backup/Version Control**| β
Easy to manage with secrets managers | β Binary files, harder to manage |
|
| 412 |
+
| **Auto-Refresh** | β
Uses refresh tokens | β
Uses refresh tokens |
|
| 413 |
+
| **Recommended For** | Production deployments | Local development / testing |
|
| 414 |
+
|
| 415 |
+
**Best Practice**: Always export to environment variables for VPS/cloud deployments.
|
| 416 |
+
|
| 417 |
+
---
|
| 418 |
+
|
| 419 |
+
### Production Deployment Checklist
|
| 420 |
+
|
| 421 |
+
#### Security Best Practices
|
| 422 |
+
|
| 423 |
+
- [ ] Never commit `.env` or `oauth_creds/` to version control
|
| 424 |
+
- [ ] Use environment variables instead of credential files in production
|
| 425 |
+
- [ ] Secure your VPS firewall - **do not** open OAuth callback ports (51121, 8085, 11451) to public internet
|
| 426 |
+
- [ ] Use SSH port forwarding only during initial authentication
|
| 427 |
+
- [ ] Rotate credentials regularly using the credential tool's export feature
|
| 428 |
+
- [ ] Set file permissions on `.env`: `chmod 600 .env`
|
| 429 |
+
|
| 430 |
+
#### Firewall Configuration
|
| 431 |
+
|
| 432 |
+
OAuth callback ports should **never** be publicly exposed:
|
| 433 |
+
|
| 434 |
+
```bash
|
| 435 |
+
# β DO NOT DO THIS - keeps ports closed
|
| 436 |
+
# sudo ufw allow 51121/tcp
|
| 437 |
+
# sudo ufw allow 8085/tcp
|
| 438 |
+
# sudo ufw allow 11451/tcp
|
| 439 |
+
|
| 440 |
+
# β
Only open your proxy API port
|
| 441 |
+
sudo ufw allow 8000/tcp
|
| 442 |
+
|
| 443 |
+
# Check firewall status
|
| 444 |
+
sudo ufw status
|
| 445 |
+
```
|
| 446 |
+
|
| 447 |
+
The SSH tunnel method works **without** opening these ports because traffic routes through the SSH connection (port 22).
|
| 448 |
+
|
| 449 |
+
#### Running as a Service
|
| 450 |
+
|
| 451 |
+
Create a systemd service file on your VPS:
|
| 452 |
+
|
| 453 |
+
```bash
|
| 454 |
+
# Create service file
|
| 455 |
+
sudo nano /etc/systemd/system/llm-proxy.service
|
| 456 |
+
```
|
| 457 |
+
|
| 458 |
+
```ini
|
| 459 |
+
[Unit]
|
| 460 |
+
Description=LLM API Key Proxy
|
| 461 |
+
After=network.target
|
| 462 |
+
|
| 463 |
+
[Service]
|
| 464 |
+
Type=simple
|
| 465 |
+
User=your-username
|
| 466 |
+
WorkingDirectory=/path/to/LLM-API-Key-Proxy
|
| 467 |
+
Environment="PATH=/path/to/python/bin"
|
| 468 |
+
ExecStart=/path/to/python/bin/uvicorn src.proxy_app.main:app --host 0.0.0.0 --port 8000
|
| 469 |
+
Restart=always
|
| 470 |
+
RestartSec=10
|
| 471 |
+
|
| 472 |
+
[Install]
|
| 473 |
+
WantedBy=multi-user.target
|
| 474 |
+
```
|
| 475 |
+
|
| 476 |
+
```bash
|
| 477 |
+
# Enable and start the service
|
| 478 |
+
sudo systemctl daemon-reload
|
| 479 |
+
sudo systemctl enable llm-proxy
|
| 480 |
+
sudo systemctl start llm-proxy
|
| 481 |
+
|
| 482 |
+
# Check status
|
| 483 |
+
sudo systemctl status llm-proxy
|
| 484 |
+
|
| 485 |
+
# View logs
|
| 486 |
+
sudo journalctl -u llm-proxy -f
|
| 487 |
+
```
|
| 488 |
+
|
| 489 |
+
---
|
| 490 |
+
|
| 491 |
+
### Troubleshooting VPS Deployment
|
| 492 |
+
|
| 493 |
+
#### "localhost:51121 connection refused" Error
|
| 494 |
+
|
| 495 |
+
**Cause**: Trying to authenticate directly on VPS without SSH tunnel.
|
| 496 |
+
|
| 497 |
+
**Solution**: Use Option 1 (authenticate locally) or Option 2 (SSH port forwarding).
|
| 498 |
+
|
| 499 |
+
#### OAuth Credentials Not Loading
|
| 500 |
+
|
| 501 |
+
```bash
|
| 502 |
+
# Check if environment variables are set
|
| 503 |
+
printenv | grep -E '(ANTIGRAVITY|GEMINI_CLI|IFLOW|QWEN_CODE)'
|
| 504 |
+
|
| 505 |
+
# Verify .env file exists and is readable
|
| 506 |
+
ls -la .env
|
| 507 |
+
cat .env | grep -E '(ANTIGRAVITY|GEMINI_CLI|IFLOW|QWEN_CODE)'
|
| 508 |
+
|
| 509 |
+
# Check credential files if using file-based approach
|
| 510 |
+
ls -la oauth_creds/
|
| 511 |
+
```
|
| 512 |
+
|
| 513 |
+
#### Token Refresh Failing
|
| 514 |
+
|
| 515 |
+
The proxy automatically refreshes tokens using refresh tokens. If refresh fails:
|
| 516 |
+
|
| 517 |
+
1. **Re-authenticate**: Run credential tool again and export new credentials
|
| 518 |
+
2. **Check token expiry**: Some providers require periodic re-authentication
|
| 519 |
+
3. **Verify credentials**: Ensure `REFRESH_TOKEN` is present in environment variables
|
| 520 |
+
|
| 521 |
+
#### Permission Denied on .env
|
| 522 |
+
|
| 523 |
+
```bash
|
| 524 |
+
# Set correct permissions
|
| 525 |
+
chmod 600 .env
|
| 526 |
+
chown your-username:your-username .env
|
| 527 |
+
```
|
| 528 |
+
|
| 529 |
+
---
|
| 530 |
+
|
| 531 |
+
### Summary: VPS Deployment Best Practices
|
| 532 |
+
|
| 533 |
+
1. **Authenticate locally** on your development machine (easiest, most secure)
|
| 534 |
+
2. **Export to environment variables** using the credential tool's built-in export feature
|
| 535 |
+
3. **Deploy to VPS** by adding environment variables to `.env`
|
| 536 |
+
4. **Never open OAuth callback ports** to the public internet
|
| 537 |
+
5. **Use SSH port forwarding** only if you must authenticate directly on VPS
|
| 538 |
+
6. **Run as a systemd service** for production reliability
|
| 539 |
+
7. **Monitor logs** for authentication errors and token refresh issues
|
| 540 |
+
|
| 541 |
+
This approach ensures secure, production-ready deployment while maintaining the convenience of OAuth authentication.
|
| 542 |
+
|