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
When tokens are refreshed, the credential files are automatically updated:
205
+
206
+
-`~/.claude/.credentials.json` - Updated with new Claude tokens
207
+
-`~/.qwen/oauth_creds.json` - Updated with new Qwen tokens
208
+
209
+
File permissions are preserved (0600 - user read/write only).
210
+
133
211
## Provider Registry Integration
134
212
135
213
The provider registry in `internal/services/provider_registry.go` automatically:
@@ -320,8 +398,10 @@ if available, ok := info["available"].(bool); ok && available {
320
398
321
399
| File | Action | Description |
322
400
|------|--------|-------------|
323
-
|`internal/auth/oauth_credentials/oauth_credentials.go`| Created | OAuth credential reader |
401
+
|`internal/auth/oauth_credentials/oauth_credentials.go`| Created | OAuth credential reader with auto-refresh |
402
+
|`internal/auth/oauth_credentials/token_refresh.go`| Created | Token auto-refresh mechanism |
324
403
|`internal/auth/oauth_credentials/oauth_credentials_test.go`| Created | Unit tests |
404
+
|`internal/auth/oauth_credentials/token_refresh_test.go`| Created | Auto-refresh tests |
325
405
|`internal/llm/providers/claude/claude.go`| Modified | OAuth support |
326
406
|`internal/llm/providers/qwen/qwen.go`| Modified | OAuth support |
327
407
|`internal/services/provider_registry.go`| Modified | Auto OAuth selection |
@@ -347,7 +427,9 @@ if available, ok := info["available"].(bool); ok && available {
347
427
348
428
### Token Expired
349
429
350
-
OAuth tokens typically expire after several hours. Re-authenticate via:
430
+
OAuth tokens typically expire after several hours. The auto-refresh mechanism will automatically refresh tokens before they expire if a refresh token is available.
431
+
432
+
If auto-refresh fails or no refresh token exists, re-authenticate via:
351
433
```bash
352
434
# Claude Code
353
435
claude --login
@@ -356,6 +438,13 @@ claude --login
356
438
qwen --login
357
439
```
358
440
441
+
### Checking Refresh Status
442
+
443
+
```go
444
+
status:= oauth_credentials.GetRefreshStatus()
445
+
// Check if tokens need refresh or have refresh tokens available
446
+
```
447
+
359
448
### Environment Variable Not Working
360
449
361
450
Both spellings are supported:
@@ -381,6 +470,17 @@ Some providers may return 401 on health check endpoints even with valid OAuth cr
381
470
OAuth2 credential integration provides seamless authentication for users already logged into Claude Code or Qwen Code CLI agents. The implementation is:
382
471
383
472
-**Backward Compatible**: Falls back to API keys when OAuth unavailable
384
-
-**Secure**: Respects token expiration and doesn't store credentials
473
+
-**Auto-Refreshing**: Automatically refreshes tokens before expiration
474
+
-**Secure**: Respects token expiration and safely updates credential files
385
475
-**Transparent**: Logs which authentication method is active
386
-
-**Tested**: Comprehensive unit and integration test coverage
476
+
-**Tested**: Comprehensive unit and integration test coverage (35+ tests)
477
+
478
+
### Auto-Refresh Summary
479
+
480
+
| Feature | Claude | Qwen |
481
+
|---------|--------|------|
482
+
| Proactive refresh | 10 min before expiry | 10 min before expiry |
0 commit comments