You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarification Needed: OAuth2 Authorization Code Flow Requirements for MCP Server Integration #3621
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:
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:
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?
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?
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.
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
@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.
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/).
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.
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?
@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.
Activity
seanzhou1023 commentedon Nov 20, 2025
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
seanzhou1023 commentedon Nov 20, 2025
I think Agent Engine doesn't support ADK web yet, so you have to handle the callback yourself.
hasanali-aa commentedon Nov 21, 2025
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
guilmour commentedon Jan 20, 2026
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?
surajksharma07 commentedon Feb 4, 2026
@priyayarrabolu-boop Latest ADK (post v1.23.0) now supports OAuth2 auth natively on McpToolset — pass
auth_schemeandauth_credentialparams 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_credentialevent from the runner, open theauth_urifor user consent, then send back the access token as aFunctionResponse.See the working example at
contributing/samples/mcp_toolset_auth/in the repo.surajksharma07 commentedon Feb 4, 2026
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/).surajksharma07 commentedon Feb 8, 2026
The McpToolset OAuth2 auth feature (commit
798f65df) has shipped in v1.24.0.Upgrading to
google-adk>=1.24.0gives you full authorization code flow support in ADK Web — passauth_schemeandauth_credentialtoMcpToolsetand the UI handles redirect + token exchange automatically (seecontributing/samples/mcp_toolset_auth/).For Agent Engine deployments, manual callback handling is still needed.
Closing this issue for the ADK Web use case.
mashanm commentedon Feb 23, 2026
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?
surajksharma07 commentedon Feb 25, 2026
@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_credentialatMcpToolsetinit time (which is service-level and shared).To get per-user tokens, use
auth_schemewith the authorization code flow and let the UI-driven redirect handle it — each user's token will then be scoped to their session independently.