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
Google ADK Authentication Token Not Passed to Tool Context #267
Bug Report: Google ADK Authentication Token Not Passed to Tool Context
Describe the bug
When using Google ADK with HTTP Bearer authentication, the bearer token provided in the request is not properly passed to the tool_context in custom tools. The tool_context.actions.requested_auth_configs dictionary remains empty even when authentication information is properly provided in the request.
To Reproduce
Steps to reproduce the behavior:
Create a custom tool that requires authentication using the ADK framework
Configure the tool to use HTTP Bearer authentication
Send a request with authentication information in one of these ways:
HTTP Authorization header with a Bearer token
In the request body under actions.requested_auth_configs
In the tool, attempt to access tool_context.actions.requested_auth_configs
See that the dictionary is empty and the token is not accessible
Expected behavior
When a bearer token is provided in the request (either through headers or in the body), ADK should pass this token to the tool through tool_context.actions.requested_auth_configs, making it accessible using the standard ADK authentication flow with tool_context.get_auth_response().
Screenshots
N/A
Desktop (please complete the following information):
OS: macOS 24.4.0
Python version: 3.13
ADK version: The latest version (as installed by default in April 2025)
Additional context
This appears to be an issue with how ADK's main runner processes authentication information. In the code of runners.py, the authentication information from the request body is not properly transferred to the event_actions object that's passed to the tool_context.
and client send back the auth credential as response.
If client needs to actively pass in auth credential to tools, you can directly pass in the session.state, and if you want it to be removed after one invocation you can append the key with 'temp:' namespace, see https://google.github.io/adk-docs/tools/#state-management
Activity
MagnusDot commentedon Apr 18, 2025
{ "app_name": "ServaneAI", "user_id": "1", "session_id": "21fa9be4-12d0-4c64-af80-5a3c168fdcfc", "new_message": { "parts": [ { "text": "what time is it in new york" } ], "role": "User" }, "streaming": false }the body passed to the /run
and the headers :
dkmin commentedon Apr 19, 2025
+1
MagnusDot commentedon Apr 20, 2025
I made a MR to repare it
seanzhou1023 commentedon May 27, 2025
sorry we didn't provide enough documents.
auth response is not passed in this way. It should be only passed as a function response to adk_request_credential, please see : https://github.com/google/adk-docs/blob/main/docs/tools/authentication.md
tool_context.actions.requested_auth_configs is not something that is supposed to be touch out of adk.
seanzhou1023 commentedon May 27, 2025
and this is only used when tools are requesting credential on demand. e.g. :
adk-python/contributing/samples/oauth_calendar_agent/agent.py
Line 54 in 5d2a876
and client send back the auth credential as response.
If client needs to actively pass in auth credential to tools, you can directly pass in the session.state, and if you want it to be removed after one invocation you can append the key with 'temp:' namespace, see https://google.github.io/adk-docs/tools/#state-management