chipflow.auth¶
ChipFlow authentication helper module.
Handles authentication for ChipFlow API with multiple fallback methods: 1. Environment variable CHIPFLOW_API_KEY 2. GitHub CLI token authentication (if gh is available) 3. OAuth 2.0 Device Flow
Exceptions¶
Exception raised when authentication fails. |
Functions¶
Get path to credentials file. |
|
|
Save API key to credentials file. |
Load API key from credentials file if it exists. |
|
Check if GitHub CLI is installed and authenticated. |
|
Get GitHub token from gh CLI. |
|
|
Authenticate using GitHub CLI token. |
|
Authenticate using OAuth 2.0 Device Flow. |
|
Get API key using the following priority: |
|
Remove saved credentials. |
Module Contents¶
- exception chipflow.auth.AuthenticationError¶
Bases:
ExceptionException raised when authentication fails.
- chipflow.auth.get_credentials_file()¶
Get path to credentials file.
- chipflow.auth.load_saved_api_key()¶
Load API key from credentials file if it exists.
- chipflow.auth.is_gh_authenticated()¶
Check if GitHub CLI is installed and authenticated.
- chipflow.auth.get_gh_token()¶
Get GitHub token from gh CLI.
- chipflow.auth.authenticate_with_github_token(api_origin, interactive=True)¶
Authenticate using GitHub CLI token.
- chipflow.auth.authenticate_with_device_flow(api_origin, interactive=True)¶
Authenticate using OAuth 2.0 Device Flow.
- chipflow.auth.get_api_key(api_origin=None, interactive=True, force_login=False)¶
Get API key using the following priority: 1. CHIPFLOW_API_KEY environment variable 2. Saved credentials file (unless force_login is True) 3. GitHub CLI token authentication 4. Device flow authentication
- Parameters:
- Returns:
API key string
- Raises:
AuthenticationError – If all authentication methods fail
- chipflow.auth.logout()¶
Remove saved credentials.