Commit ac99770
fix(auth): allow configuring OAuth prompt parameter
Merge #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=#5818 from RaghunandanKumar:fix/oauth-prompt-configurable 727e2e5
PiperOrigin-RevId: 9435531061 parent a721c1e commit ac99770
3 files changed
Lines changed: 24 additions & 2 deletions
File tree
- src/google/adk/auth
- tests/unittests/auth
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
251 | 253 | | |
252 | 254 | | |
253 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
254 | 275 | | |
255 | 276 | | |
256 | 277 | | |
| |||
299 | 320 | | |
300 | 321 | | |
301 | 322 | | |
302 | | - | |
| 323 | + | |
303 | 324 | | |
304 | 325 | | |
305 | 326 | | |
| |||
0 commit comments