Description
Here's the bug report using the provided template:
Describe the bug
GmailToolset OAuth flow generates malformed authorization URLs where the flowName=GeneralOAuthFlow
parameter is incorrectly appended to the redirect_uri
value instead of being a separate query parameter, causing redirect_uri_mismatch
errors in Google OAuth.
To Reproduce
Steps to reproduce the behavior:
- Install
google-adk
package - Create a GmailToolset with OAuth credentials:
from google.adk.tools.google_api_tool.google_api_toolsets import GmailToolset gmail_toolset = GmailToolset( client_id="your-client-id", client_secret="your-client-secret", tool_filter=['gmail_users_drafts_create'] )
- Deploy to Google Cloud Run and trigger any Gmail tool function
- Observe OAuth authorization URL contains malformed redirect_uri:
redirect_uri=https://your-url.run.app/dev-ui/ flowName=GeneralOAuthFlow
(contains a whitespace)
Expected behavior
OAuth authorization URL should have properly separated query parameters:
redirect_uri=https://your-url.run.app/dev-ui/?flowName=GeneralOAuthFlow
Note: '?' instead of whitespace or not be there at all?
Error message
Error from Google OAuth:
Error 400: redirect_uri_mismatch
Request details: redirect_uri=https://my-cloud-run-app.us-central1.run.app/dev-ui/ flowName=GeneralOAuthFlow
Note: There is a space between the URL and "flowName", indicating the flowName is being incorrectly appended to the redirect_uri value instead of being handled separately.
Desktop (please complete the following information):
- OS: macOS
- Python version: Python 3.13.0
- ADK version: 1.2.1 (installed from pip)
Additional context
- Issue occurs in
google/adk/auth/auth_handler.py
around line 244-250 in thegenerate_auth_uri()
method: GmailToolset
constructor doesn't acceptredirect_uri
parameter, causingauth_credential.oauth2.redirect_uri
to beNone
- The
flowName
parameter gets incorrectly concatenated to the redirect_uri value instead of being a separate query parameter - This affects all Google API toolsets using OAuth2 flows
- Registered redirect URI in Google Cloud Console matches the base URL but fails due to the malformed parameter