Skip to content

How to route pass through an access token in AWS Bedrock AgentCore?

1

I would like to use a user-provided access token as the outbound OAuth token in AgentCore Gateway. Can I somehow provide and pass through the access token from my MCP client when calling the /mcp endpoint of the AgentCore Gateway?

2 Answers
5

How about this:

  1. Configure JWT Inbound Authentication To accept a user-provided access token, you need to configure your AgentCore runtime to support JWT bearer tokens. • Define an authorizer configuration during agent creation: o Discovery URL: Must match the OpenID Connect discovery pattern (e.g., https://auth.example.com/.well-known/openid-configuration) o Allowed audiences: Matches the aud claim in the token o Allowed clients: Matches the client_id claim

  2. Include User Token in Request Header When calling the /mcp endpoint, include the token in the request header:

Authorization: Bearer <user-access-token>
X-Amzn-Bedrock-AgentCore-Runtime-User-Id: <user-id>

This allows the agent to associate the request with the correct user context. 3. Enable OAuth Outbound Access To use the token for outbound OAuth calls (e.g., accessing third-party APIs): • Configure your agent to use the token as part of its outbound request logic. • You can use AgentCore’s EZ Auth or custom logic to forward the token to external services.

EXPERT
answered 8 months ago
  • Configure your agent to use the token as part of its outbound request logic. • You can use AgentCore’s EZ Auth or custom logic to forward the token to external services.

    Not sure if I got this part. Can I simply reuse the token from the inbound authentication? I understand that I can either configure a token or an access key... however, I can't get a new token from an IdP as I don't want to use a machine user or a key.

  • Running into the same issue here and have the same question. I'm able to authenticate via user token for inbound auth, but how are we supposed to pass the user token through? The only options currently available seem to be API Key & OAuth client.

0

I solved this by creating a interceptor. https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_UpdateGateway.html#bedrockagentcorecontrol-UpdateGateway-request-authorizerConfiguration

Call this with AwsSdkCall in the cdk to add the interceptor lambda to the gateway. Then forwardward the token details from the interceptor to the tool. Works like a charm.

answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.