ccproxy.auth.openai¶
ccproxy.auth.openai
¶
OpenAI authentication components for Codex integration.
OpenAICredentials
¶
Bases: BaseModel
OpenAI authentication credentials model.
parse_expires_at
classmethod
¶
Parse expiration timestamp.
Source code in ccproxy/auth/openai/credentials.py
extract_account_id
classmethod
¶
Extract account ID from access token if not provided.
Source code in ccproxy/auth/openai/credentials.py
is_expired
¶
expires_in_seconds
¶
to_dict
¶
Convert to dictionary for storage.
Source code in ccproxy/auth/openai/credentials.py
OpenAITokenManager
¶
Manages OpenAI token storage and refresh operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
storage
|
OpenAITokenStorage | None
|
Token storage backend. If None, uses default TOML file storage. |
None
|
Source code in ccproxy/auth/openai/credentials.py
load_credentials
async
¶
Load credentials from storage.
Source code in ccproxy/auth/openai/credentials.py
save_credentials
async
¶
Save credentials to storage.
Source code in ccproxy/auth/openai/credentials.py
delete_credentials
async
¶
Delete credentials from storage.
Source code in ccproxy/auth/openai/credentials.py
has_credentials
async
¶
get_valid_token
async
¶
Get a valid access token, refreshing if necessary.
Source code in ccproxy/auth/openai/credentials.py
OpenAIOAuthClient
¶
OpenAI OAuth PKCE flow client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settings
|
CodexSettings
|
Codex configuration settings |
required |
token_manager
|
OpenAITokenManager | None
|
Token manager for credential storage |
None
|
Source code in ccproxy/auth/openai/oauth_client.py
authenticate
async
¶
Perform OAuth PKCE flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
open_browser
|
bool
|
Whether to automatically open browser |
True
|
Returns:
Type | Description |
---|---|
OpenAICredentials
|
OpenAI credentials |
Raises:
Type | Description |
---|---|
ValueError
|
If authentication fails |
Source code in ccproxy/auth/openai/oauth_client.py
OpenAITokenStorage
¶
JSON file-based storage for OpenAI credentials using Codex format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
Path | None
|
Path to JSON file. If None, uses ~/.codex/auth.json |
None
|
Source code in ccproxy/auth/openai/storage.py
load
async
¶
Load credentials from Codex JSON file.
Source code in ccproxy/auth/openai/storage.py
save
async
¶
Save credentials to Codex JSON file.
Source code in ccproxy/auth/openai/storage.py
exists
async
¶
Check if credentials file exists.
Source code in ccproxy/auth/openai/storage.py
delete
async
¶
Delete credentials file.