ccproxy.plugins.oauth_claude.manager¶
ccproxy.plugins.oauth_claude.manager
¶
Claude API token manager implementation for the Claude API plugin.
TokenRefreshProvider
¶
ClaudeApiTokenManager
¶
Bases: EnhancedTokenManager[ClaudeCredentials]
Manager for Claude API token storage and refresh operations.
Uses the Claude-specific storage implementation with enhanced token management.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage
|
TokenStorage[ClaudeCredentials] | None
|
Optional custom storage, defaults to standard location |
None
|
http_client
|
AsyncClient | None
|
Optional HTTP client for API requests |
None
|
oauth_provider
|
TokenRefreshProvider | None
|
Optional OAuth provider for token refresh (protocol injection) |
None
|
Source code in ccproxy/plugins/oauth_claude/manager.py
create
async
classmethod
¶
Async factory that constructs the manager and preloads cached profile.
This avoids creating event loops in init and keeps initialization non-blocking.
Source code in ccproxy/plugins/oauth_claude/manager.py
preload_profile_cache
async
¶
Load profile from storage asynchronously if available.
Source code in ccproxy/plugins/oauth_claude/manager.py
get_access_token
async
¶
Get access token using enhanced base with automatic refresh.
Source code in ccproxy/plugins/oauth_claude/manager.py
refresh_token_if_needed
async
¶
Use enhanced base's automatic refresh capability.
refresh_token
async
¶
Refresh the access token using the refresh token.
Returns:
| Type | Description |
|---|---|
ClaudeCredentials | None
|
Updated credentials or None if refresh failed |
Source code in ccproxy/plugins/oauth_claude/manager.py
is_expired
¶
Check if credentials are expired using wrapper.
Source code in ccproxy/plugins/oauth_claude/manager.py
load_credentials
async
¶
Load credentials and backfill subscription_type from profile if missing.
Avoids network calls; uses cached profile or local ~/.claude/.account.json and writes back only when the field actually changes.
Source code in ccproxy/plugins/oauth_claude/manager.py
get_account_id
¶
Get account ID from credentials.
Claude doesn't store account_id in tokens, would need to fetch from profile API.
Source code in ccproxy/plugins/oauth_claude/manager.py
get_expiration_time
¶
Get expiration time as datetime.
get_profile_quick
async
¶
Return cached profile info only, avoiding I/O or network.
Profile cache is typically preloaded from local storage by the async factory create() via preload_profile_cache().
Returns:
| Type | Description |
|---|---|
ClaudeProfileInfo | None
|
Cached ClaudeProfileInfo or None |
Source code in ccproxy/plugins/oauth_claude/manager.py
get_access_token_value
async
¶
Get the actual access token value.
Returns:
| Type | Description |
|---|---|
str | None
|
Access token string if available, None otherwise |
Source code in ccproxy/plugins/oauth_claude/manager.py
get_profile
async
¶
Get user profile from cache or API.
Returns:
| Type | Description |
|---|---|
ClaudeProfileInfo | None
|
ClaudeProfileInfo or None if not authenticated |
Source code in ccproxy/plugins/oauth_claude/manager.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
close
async
¶
Close the HTTP client if it was created internally.