- Newest
- Most votes
- Most comments
When using Amazon Bedrock AgentCore with JWT authentication, you cannot use the AWS SDK (boto3) to call invoke_agent_runtime directly with JWT tokens. According to the documentation, if you're integrating your agent with OAuth, you need to make an HTTPS request to InvokeAgentRuntime instead of using the boto3 client.
This explains why you're getting the parameter validation error when trying to pass the JWT token in the headers parameter - the boto3 client for bedrock-agentcore doesn't support passing authorization headers this way.
For agents configured with JWT authentication, you need to:
- Make a direct HTTPS request to the InvokeAgentRuntime endpoint
- Include your JWT token in the Authorization header
- Format your request according to the AgentCore API requirements
Your second approach using STS/OIDC to assume a role and then using the temporary credentials with boto3 works because you're switching the authentication method to IAM (SigV4) instead of JWT. This is why you had to reconfigure your agent runtime to use IAM identity.
If you must use JWT authentication with your existing IdP and need the token available in your agent tools, you have two options:
- Continue using the direct HTTPS request approach with JWT authentication
- Pass the token as part of your payload data when using the boto3 client with IAM authentication, so your agent can extract and use it from the payload
The second option allows you to keep using boto3 while still making the token available to your agent, though you'd need to modify your agent code to extract the token from the payload rather than from the headers.
Sources
invoke_agent_runtime - Boto3 1.40.3 documentation
How to route pass through an access token in AWS Bedrock AgentCore? | AWS re:Post
Introducing Amazon Bedrock AgentCore Identity: Securing agentic AI at scale | Artificial Intelligence
answered a year ago
In order to enable Auth Token propagation directly at the AgentCore Runtime level please consider using the custom headers feature. Custom headers let you pass contextual information from your application directly to your agent code without cluttering the main request payload. This includes authentication tokens like JWT (JSON Web Tokens, which contain user identity and authorization claims) through the Authorization header, allowing your agent to make decisions based on who is calling it.
Source: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-header-allowlist.html
answered 7 months ago
Relevant content
- AWS OFFICIALUpdated 4 years ago
