Files
Naishadam Raghunandan Kumar ac99770646 fix(auth): allow configuring OAuth prompt parameter
Merge https://github.com/google/adk-python/pull/5818

Closes #3046

## Summary

`AuthHandler.generate_auth_uri()` currently hardcodes `prompt=consent` when building OAuth authorization URLs.

That makes app-level OAuth configuration less flexible than the underlying providers allow. Flows that need `prompt=none` (or another prompt mode) cannot express that through `OAuth2Auth`, even though the rest of the OAuth request metadata is already configurable.

This change adds an optional `prompt` field to `OAuth2Auth`, preserves `consent` as the default, and uses the configured value when generating the authorization URL.

## Changes

- `src/google/adk/auth/auth_credential.py`
  - Add optional `prompt` field to `OAuth2Auth`.
- `src/google/adk/auth/auth_handler.py`
  - Use `auth_credential.oauth2.prompt or "consent"` when populating OAuth authorization params.
- `tests/unittests/auth/test_auth_handler.py`
  - Extend the OAuth session test double to surface `prompt` in generated auth URIs.
  - Assert the default OAuth flow still includes `prompt=consent`.
  - Add coverage for a custom `prompt="none"` override.

## Test plan

- [x] `python3.12 -m py_compile src/google/adk/auth/auth_credential.py src/google/adk/auth/auth_handler.py tests/unittests/auth/test_auth_handler.py`
- [ ] `PYTHONPATH=src .venv/bin/python -m pytest tests/unittests/auth/test_auth_handler.py -q`
  - Blocked locally while bootstrapping a minimal ad hoc venv: importing `google.adk` for this test path pulls additional runtime dependencies (`google.genai`, `opentelemetry.semconv`, and friends). I stopped after confirming the touched files compile cleanly rather than trying to recreate the repo's full `uv sync --all-extras` environment by hand.
- [ ] Reviewer / CI confirmation that the existing auth handler unit suite passes in the standard repo environment.

Co-authored-by: George Weale <gweale@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/5818 from RaghunandanKumar:fix/oauth-prompt-configurable 727e2e59884a01f5b2e9c825300a3e9f8d35456d
PiperOrigin-RevId: 943553106
2026-07-06 16:26:04 -07:00
..
2026-01-20 14:50:09 -08:00