GmailToolset OAuth redirect_uri malformed with appended flowName parameter
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-adkpackage - 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.pyaround line 244-250 in thegenerate_auth_uri()method: GmailToolsetconstructor doesn't acceptredirect_uriparameter, causingauth_credential.oauth2.redirect_urito beNone- The
flowNameparameter 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
I'm observing this (4)"flowName=GeneralOAuthFlow (contains a whitespace)" in firebase auth. This may prevent firebase auth from working using Google accounts.
I encountered the same issue with redirect url. I just used https://your-url.run.app/dev-ui/ without "flowName=GeneralOAuthFlow" in the oauth configuration and it worked fine.
Hi @SAMFVH and thanks to everyone who participated in this thread.
We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.
If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.
Thanks for your contribution and understanding!