Get API key from keyring or fallback file. Returns: API key or None if not set
(self)
| 246 | raise ConfigurationError(f"Failed to save configuration: {e}") |
| 247 | |
| 248 | def get_api_key(self) -> Optional[str]: |
| 249 | """ |
| 250 | Get API key from keyring or fallback file. |
| 251 | |
| 252 | Returns: |
| 253 | API key or None if not set |
| 254 | """ |
| 255 | if self._api_key is None: |
| 256 | if self._keyring_available: |
| 257 | try: |
| 258 | self._api_key = keyring.get_password(KEYRING_SERVICE, KEYRING_API_KEY_ACCOUNT) |
| 259 | except (KeyringError, Exception): |
| 260 | pass |
| 261 | if self._api_key is None: |
| 262 | self._api_key = self._load_api_key_from_file() |
| 263 | |
| 264 | return self._api_key |
| 265 | |
| 266 | def get_config(self) -> Optional[Configuration]: |
| 267 | """ |
no test coverage detected