Skip to content

feat: add opt-in OAuth auth mode (auth_mode="oauth") - #1

Open
karolzlot wants to merge 1 commit into
jarek108:mainfrom
karolzlot:main
Open

feat: add opt-in OAuth auth mode (auth_mode="oauth")#1
karolzlot wants to merge 1 commit into
jarek108:mainfrom
karolzlot:main

Conversation

@karolzlot

Copy link
Copy Markdown

Adds a new auth_mode kwarg to run_gemini_cli_headless(...) to allow users authenticated via gemini auth login (OAuth / subscription flow) to use the wrapper without a GEMINI_API_KEY.

The default behavior (auth_mode="api_key") remains fully backward-compatible. The previous code always raised ValueError("GEMINI_API_KEY is missing."), which blocked users relying solely on OAuth credentials.

Key Changes

  • gemini_cli_headless.py: Added auth_mode parameter. When set to "oauth", it skips the API key requirement and strips inherited GEMINI_API_KEY and GEMINI_CLI_HOME from the subprocess environment so the underlying CLI can resolve OAuth credentials natively.
  • Testing: Added mock-based unit tests in tests/test_auth_mode.py that verify both authentication modes and isolation behaviors without requiring a real API key.
  • Documentation: Updated README.md and docs/ with OAuth usage examples.
  • Version: Bumped version to 5.1.0 in pyproject.toml.

Test plan

  • pytest tests/test_auth_mode.py passes locally (keyless).
  • pytest tests/test_quota_greedy_fix.py passes.
  • Reviewer runs tests/integration/ with a real API key to confirm the default path is unchanged.
  • Manual smoke test by an OAuth user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant