ccproxy.auth.oauth.base¶
ccproxy.auth.oauth.base
¶
Base OAuth client with common PKCE flow implementation.
BaseOAuthClient
¶
BaseOAuthClient(
client_id,
redirect_uri,
base_url,
scopes,
storage=None,
http_client=None,
hook_manager=None,
settings=None,
)
Bases: ABC, Generic[CredentialsT]
Abstract base class for OAuth PKCE flow implementations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_id
|
str
|
OAuth client ID |
required |
redirect_uri
|
str
|
OAuth callback redirect URI |
required |
base_url
|
str
|
OAuth provider base URL |
required |
scopes
|
list[str]
|
List of OAuth scopes to request |
required |
storage
|
TokenStorage[CredentialsT] | None
|
Optional token storage backend |
None
|
http_client
|
AsyncClient | None
|
Optional HTTP client (for request tracing support) |
None
|
hook_manager
|
Any | None
|
Optional hook manager for emitting events |
None
|
settings
|
Settings | None
|
Optional settings for HTTP client configuration |
None
|
Source code in ccproxy/auth/oauth/base.py
close
async
¶
parse_token_response
abstractmethod
async
¶
get_custom_auth_params
¶
get_custom_token_params
¶
get_custom_headers
¶
authenticate
async
¶
Start OAuth authentication flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code_verifier
|
str | None
|
Optional pre-generated PKCE verifier |
None
|
state
|
str | None
|
Optional pre-generated state parameter |
None
|
Returns:
| Type | Description |
|---|---|
tuple[str, str, str]
|
Tuple of (auth_url, code_verifier, state) |
Source code in ccproxy/auth/oauth/base.py
handle_callback
async
¶
Handle OAuth callback and exchange code for tokens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
Authorization code from callback |
required |
state
|
str
|
State parameter from callback |
required |
code_verifier
|
str
|
PKCE code verifier |
required |
Returns:
| Type | Description |
|---|---|
CredentialsT
|
Provider-specific credentials object |
Raises:
| Type | Description |
|---|---|
OAuthError
|
If callback handling fails |