🔒 HTTP Bearer in ADK #2802
-
Example Scenario: Using JWT in ADK-Python for Authenticated User CRUDHi community, I’d like to discuss a basic scenario and get guidance on securely handling JWT tokens within the agent flow. ScenarioSuppose we have a tool that performs basic CRUD operations on user accounts. Only authenticated users can modify their own data. We want to use JWT tokens for authentication. The questions are:
Example Flow
I’d love to see an example or discussion about the recommended way to handle this in ADK-Python, especially how to extract the JWT payload safely and integrate it into the flow of the agent. Thanks for any guidance or examples! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Use the "User Auth" pattern with an Hi PanchoG17, Thanks for the great question. This is a common and important scenario for building secure agents. Here's a breakdown of the recommended way to handle JWT-based authentication in ADK-Python, addressing your specific points. 1. How to securely extract the
|
Beta Was this translation helpful? Give feedback.
-
Have you found a solution yet? |
Beta Was this translation helpful? Give feedback.
-
Shouldn't the ADK/Agent be able to extract headers from the HTTP post request simply? |
Beta Was this translation helpful? Give feedback.
-
@PanchoG17 thank you for your question. the step 1, 2, 3 in your example flow need to be handled by your agent server (similar as ADK API server) which runs the agent (e.g. via ADK's Runner). And once user is verified you put a signal in the adk session state, and your tools that executes the CRUD operation should check this session state to see whether the signal is there , if it's not there, then your tool should reject the operation. Better put this signal prefixed with "temp:" in the session, if your agent session is not correlated with your user session, so that it won't be persisted. |
Beta Was this translation helpful? Give feedback.
@PanchoG17 thank you for your question. the step 1, 2, 3 in your example flow need to be handled by your agent server (similar as ADK API server) which runs the agent (e.g. via ADK's Runner). And once user is verified you put a signal in the adk session state, and your tools that executes the CRUD operation should check this session state to see whether the signal is there , if it's not there, then your tool should reject the operation. Better put this signal prefixed with "temp:" in the session, if your agent session is not correlated with your user session, so that it won't be persisted.