Skip to content

Clarification Needed: OAuth2 Authorization Code Flow Requirements for MCP Server Integration #3621

Closed

Description

@priyayarrabolu-boop

Hi team,

I’m working on integrating a third-party MCP server with the Google Agent Development Kit (ADK) and would like clarification on the exact OAuth2 setup required for Authorization Code flow.

Project Setup

  • ADK agent integration with MCP server
  • ADK agent deployed in Vertex AI Agent Engine
  • Agent registered in Gemini Enterprise
  • Tools config includes auth.oauth2 with authorization and token URLs

Problem

It’s unclear from the current documentation and GitHub discussions whether ADK supports fully automatic OAuth2 authorization-code handling, or if developers must still implement the full client-side OAuth2 callback flow in their MCP servers.

The following discussions/PRs suggest that ADK handles OAuth2 partially, but do not confirm end-to-end support for the Authorization Code flow:

From my testing:

  • ADK can detect that a tool requires OAuth2
  • ADK does not present an authorization URL in the ADK Web UI
  • No redirect flow is initiated
  • No access token is received
  • It appears that ADK still expects a client-side redirect URL (/oauth/callback) and code→token exchange to be implemented manually

Key Questions

Could you please clarify:

  1. Does ADK support fully automatic OAuth2 Authorization Code flow?

    • i.e., generating the authorization URL, handling the redirect, and exchanging the code for tokens without requiring a custom callback endpoint?
  2. Or must developers still implement the full client-side OAuth2 callback flow
    including:

    • hosting the redirect URL
    • building /oauth/callback
    • doing the code→token exchange
    • passing the resulting token into ADK?
  3. If the client-side callback is required, could you provide or point to an official end-to-end example that shows how this should be implemented for use with ADK + Vertex AI Agent Engine + Gemini Enterprise?

Any concrete guidance would be greatly appreciated.

Thank you!

Activity

  1. added
    mcp
    on Nov 19, 2025
  2. added
    tools
    on Nov 19, 2025
  3. added
    planned
    on Nov 20, 2025
  4. seanzhou1023 commented on Nov 20, 2025

    @seanzhou1023
    Collaborator

    ADK web already supports the callback.

    if you want to implement the callback yourself, please follow https://google.github.io/adk-docs/tools-custom/authentication/#2-handling-the-interactive-oauthoidc-flow-client-side

  5. seanzhou1023 commented on Nov 20, 2025

    @seanzhou1023
    Collaborator

    I think Agent Engine doesn't support ADK web yet, so you have to handle the callback yourself.

  6. hasanali-aa commented on Nov 21, 2025

    @hasanali-aa

    Agent engine doesn't support the callback, but what about Gemini Enterprise? It seems to have some kind of Authorization implementation with popups for users, but it's unclear how to handle this. My attempts to implement the callback in code cause crashes from various sources

  7. guilmour commented on Jan 20, 2026

    @guilmour

    I think Agent Engine doesn't support ADK web yet, so you have to handle the callback yourself.

    How can I create the callback using the adk web?

    I did try to follow https://google.github.io/adk-docs/tools-custom/authentication/#2-handling-the-interactive-oauthoidc-flow-client-side, but i can't access the event loop of ADK Web...

    Am I missing something?

  8. added
    needs review
    on Feb 2, 2026
  9. added theissue type on Feb 2, 2026
  10. surajksharma07 commented on Feb 4, 2026

    @surajksharma07
    Collaborator

    @priyayarrabolu-boop Latest ADK (post v1.23.0) now supports OAuth2 auth natively on McpToolset — pass auth_scheme and auth_credential params and ADK Web UI handles the full authorization code flow automatically (redirect + token exchange).

    For Agent Engine deployments, you still need to handle the callback yourself: catch the adk_request_credential event from the runner, open the auth_uri for user consent, then send back the access token as a FunctionResponse.

    See the working example at contributing/samples/mcp_toolset_auth/ in the repo.

  11. removed
    needs review
    planned
    on Feb 4, 2026
  12. surajksharma07 commented on Feb 4, 2026

    @surajksharma07
    Collaborator

    Update: The McpToolset OAuth2 auth feature (commit 798f65df) landed after v1.23.0 and is not yet available in any released version — it will ship in the future releases.

    For ADK Web users, this will fully resolve the authorization code flow issue.

    For Agent Engine deployments, manual callback handling is still required (see contributing/samples/mcp_toolset_auth/).

  13. surajksharma07 commented on Feb 8, 2026

    @surajksharma07
    Collaborator

    The McpToolset OAuth2 auth feature (commit 798f65df) has shipped in v1.24.0.

    Upgrading to google-adk>=1.24.0 gives you full authorization code flow support in ADK Web — pass auth_scheme and auth_credential to McpToolset and the UI handles redirect + token exchange automatically (see contributing/samples/mcp_toolset_auth/).

    For Agent Engine deployments, manual callback handling is still needed.

    Closing this issue for the ADK Web use case.

  14. mashanm commented on Feb 23, 2026

    @mashanm

    Could you please clarify whether the credentials can be managed at user level so that each user accessing the agent can call the tools with user access token? I could see mcptoolset does not support setting up credentials key so every tool call reuses the same access token? Am I missing something or is it not supported yet?

  15. surajksharma07 commented on Feb 25, 2026

    @surajksharma07
    Collaborator

    @mashanm The authorization code flow (shipped in v1.24.0) is per-user by design — each user who accesses the agent triggers their own OAuth dance and ADK stores the resulting token in that user's session via SessionStateCredentialService, so tokens don't bleed across users.

    If you're seeing shared tokens, it's likely because you're passing a static pre-existing access token as auth_credential at McpToolset init time (which is service-level and shared).

    To get per-user tokens, use auth_scheme with the authorization code flow and let the UI-driven redirect handle it — each user's token will then be scoped to their session independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

mcptools

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions