Get API key from keyring or fallback file. Returns: API key or None if not set
(self)
| 246 | CREDENTIALS_FILE, |
| 247 | ) |
| 248 | else: |
| 249 | self._save_api_key_to_file(api_key) |
| 250 | |
| 251 | # Save non-sensitive config to JSON |
| 252 | config_data = {"version": CONFIG_VERSION, **self._config.to_dict()} |
| 253 | |
| 254 | try: |
| 255 | safe_write(CONFIG_FILE, json.dumps(config_data, indent=2)) |
| 256 | except FileSystemError as e: |
| 257 | raise ConfigurationError(f"Failed to save configuration: {e}") |
| 258 | |
| 259 | def get_api_key(self) -> Optional[str]: |
| 260 | """ |
| 261 | Get API key from keyring or fallback file. |
| 262 | |
| 263 | Returns: |
| 264 | API key or None if not set |
| 265 | """ |
| 266 | if self._api_key is None: |
| 267 | if self._keyring_available: |
no test coverage detected