ccproxy.auth.oauth¶
ccproxy.auth.oauth
¶
Public router shim for OAuth flows.
OAuthProviderProtocol
¶
Bases: Protocol
Protocol for OAuth provider implementations.
provider_display_name
property
¶
Display name for UI (e.g., 'Claude API', 'OpenAI Codex').
cli
property
¶
CLI authentication configuration for this provider.
Returns:
| Type | Description |
|---|---|
CliAuthConfig
|
Configuration object specifying CLI flow preferences and capabilities |
get_authorization_url
async
¶
Get the authorization URL for OAuth flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
str
|
OAuth state parameter for CSRF protection |
required |
code_verifier
|
str | None
|
PKCE code verifier (if PKCE is supported) |
None
|
redirect_uri
|
str | None
|
Redirect URI for OAuth callback |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Authorization URL to redirect user to |
Source code in ccproxy/auth/oauth/registry.py
handle_callback
async
¶
Handle OAuth callback and exchange code for tokens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
Authorization code from OAuth callback |
required |
state
|
str
|
State parameter for validation |
required |
code_verifier
|
str | None
|
PKCE code verifier (if PKCE is used) |
None
|
redirect_uri
|
str | None
|
Redirect URI used in the authorization request |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Provider-specific credentials object |
Source code in ccproxy/auth/oauth/registry.py
refresh_access_token
async
¶
revoke_token
async
¶
Revoke an access or refresh token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
Token to revoke |
required |
get_provider_info
¶
Get provider information for discovery.
Returns:
| Type | Description |
|---|---|
OAuthProviderInfo
|
Provider information |
get_storage
¶
Get storage implementation for this provider.
Returns:
| Type | Description |
|---|---|
Any
|
Storage implementation or None |
get_credential_summary
¶
start_device_flow
async
¶
Start OAuth device code flow.
Returns:
| Type | Description |
|---|---|
tuple[str, str, str, int]
|
Tuple of (device_code, user_code, verification_uri, expires_in) |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If device flow is not supported |
Source code in ccproxy/auth/oauth/registry.py
complete_device_flow
async
¶
Complete OAuth device code flow by polling for authorization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_code
|
str
|
Device code from start_device_flow |
required |
interval
|
int
|
Polling interval in seconds |
required |
expires_in
|
int
|
Code expiration time in seconds |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Provider-specific credentials object |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If device flow is not supported |
Source code in ccproxy/auth/oauth/registry.py
exchange_manual_code
async
¶
Exchange manually entered authorization code for tokens.
This method handles the case where users manually copy/paste authorization codes in restricted environments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
Authorization code entered manually by user |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Provider-specific credentials object |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If manual code entry is not implemented |
Source code in ccproxy/auth/oauth/registry.py
save_credentials
async
¶
Save credentials using provider's storage mechanism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credentials
|
Any
|
Provider-specific credentials object |
required |
custom_path
|
Any | None
|
Optional custom storage path |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if saved successfully, False otherwise |
Source code in ccproxy/auth/oauth/registry.py
get_oauth_flow_result
¶
register_oauth_flow
¶
Register a pending OAuth flow.