adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

fix(auth): allow configuring OAuth prompt parameter

Open RaghunandanKumar opened this issue 6 months ago • 6 comments

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.

RaghunandanKumar avatar May 23 '26 03:05 RaghunandanKumar

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar May 23 '26 03:05 google-cla[bot]

Response from ADK Triaging Agent

Hello @RaghunandanKumar, thank you for creating this PR! We appreciate your contribution to improve the flexibility of OAuth prompt configuration.

To help us review and merge your PR more efficiently, please address the following items from our contribution guidelines:

  1. Sign the Contributor License Agreement (CLA): It looks like the Google CLA check has failed. Please visit the Google CLA page to sign or verify your agreement. This is required before we can accept your contribution.
  2. Verify Unit Tests: Our guidelines require providing a summary of passed pytest results. We noticed you were blocked while setting up the local environment. Please follow the Development Setup instructions in our contribution guidelines (such as installing uv and running uv sync --all-extras) to easily run pytest ./tests/unittests locally.

Thank you!

adk-bot avatar May 23 '26 03:05 adk-bot

Hi @RaghunandanKumar , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you!

rohityan avatar May 26 '26 15:05 rohityan

I signed the CLA, but the cla/google check is still failing on the latest run from 2026-05-27. Could someone please help re-evaluate or confirm whether there is an account-linkage issue on the CLA side?

Repo-side status update remains unchanged: focused auth tests for this patch pass locally (pytest tests/unittests/auth/test_auth_handler.py -q -> 26 passed).

RaghunandanKumar avatar May 27 '26 00:05 RaghunandanKumar

I followed the repo development setup locally and ran the full unit test suite.

Local verification:

  • uv venv --python python3.11 .venv
  • uv sync --all-extras
  • pytest ./tests/unittests

Result:

  • 6708 passed, 17 skipped, 31 xfailed, 9 xpassed in 217.57s

This includes coverage for this PR's auth change, including tests/unittests/auth/test_auth_handler.py.

The remaining blocker on the PR appears to be the CLA check rather than test verification.

RaghunandanKumar avatar May 27 '26 00:05 RaghunandanKumar

@rohityan - anything you want me to do to get the approval? Please let me know

RaghunandanKumar avatar Jun 11 '26 02:06 RaghunandanKumar

Thank you @RaghunandanKumar for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit ac99770.

Closing this PR as the changes are now in the main branch.

adk-bot avatar Jul 06 '26 23:07 adk-bot