Skip to content

GmailToolset OAuth redirect_uri malformed with appended flowName parameter #1209

Open
@SAMFVH

Description

@SAMFVH

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:

  1. Install google-adk package
  2. 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']
    )
  3. Deploy to Google Cloud Run and trigger any Gmail tool function
  4. 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 the generate_auth_uri() method:
  • GmailToolset constructor doesn't accept redirect_uri parameter, causing auth_credential.oauth2.redirect_uri to be None
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions