---
title: How does Amazon Bedrock AgentCore Identity manage OAuth tokens for agents?
url: https://opencontroller.lyzr.com/blog/amazon-bedrock-agentcore-identity-token-vault
published: 2026-11-13
updated: 2026-11-13
author: Lyzr
---

# How does Amazon Bedrock AgentCore Identity manage OAuth tokens for agents?

**AgentCore Identity keeps the credentials an agent uses to call other services in a managed token vault. The agent never holds a long-lived secret in code. It swaps its workload access token for a scoped OAuth token or API key at call time, and inbound callers are checked with IAM SigV4 or a JWT authorizer.**

If you are reviewing agents built on Amazon Bedrock AgentCore, the first identity question is simple: where do the secrets live, and who can pull them? This guide walks through the moving parts, the IAM actions to watch, and the checks worth adding to your review.

## What are the parts of AgentCore Identity?

| Component | What it does |
|---|---|
| Workload identity | An identity for each agent runtime or gateway, created automatically with the runtime |
| Token vault | Stores outbound OAuth credentials, API keys and user tokens |
| OAuth2 credential provider | Configures an OAuth client for a downstream service |
| API key credential provider | Stores a static API key for a downstream service |
| Inbound authorizer | Checks who may invoke the agent: IAM SigV4 or a custom JWT authorizer |

When you create a credential provider, AgentCore returns a `credentialProviderArn` and a `secretArn`. The secret is an AWS Secrets Manager secret that AgentCore generates for that credential. Your review should treat both ARNs as sensitive resources.

## Which outbound flows are supported?

OAuth2 credential providers support three grants:

1. **Client credentials (two-legged).** Machine-to-machine access on the application's behalf.
2. **Authorization code (three-legged).** The user consents once; the agent then acts for that user.
3. **Token exchange (on-behalf-of).** The inbound user token is exchanged for a scoped downstream token. See our guide to [OAuth token exchange for agents](/blog/oauth-token-exchange-for-ai-agents).

API key providers take a key and, at the gateway target, a location (header or query parameter) and prefix such as `Bearer`.

Support varies by target type. AWS documents, for AgentCore Gateway targets:

| Gateway target | Outbound options |
|---|---|
| Lambda | Gateway service role only |
| Smithy model | Service role, OAuth client credentials |
| AgentCore Runtime (HTTP) | Service role, caller IAM, OAuth client credentials, token passthrough |
| MCP server or OpenAPI | Service role, OAuth (all three grants), API key |
| API Gateway stage | Service role, API key |

## How does a call actually get a token?

For a three-legged flow on AgentCore Runtime, AWS describes this sequence:

1. The runtime validates the inbound JWT.
2. It exchanges that JWT for a workload access token with `GetWorkloadAccessTokenForJWT`.
3. The agent calls `GetResourceOauth2Token`. If no token is cached, it receives an authorization URL.
4. The user consents; AgentCore Identity stores the token in the vault.
5. Later calls reuse the cached token until it expires.

The stored token is bound to two things: the agent's workload identity and the user ID from the inbound JWT. One agent cannot reuse another user's token, and another agent cannot reuse this agent's tokens.

In Python, the SDK's `@requires_access_token` decorator wraps this. You name the provider, the scopes and the flow, and the function receives `access_token` at run time.

## How are inbound callers checked?

Each runtime uses one inbound mode:

- **IAM SigV4** (default). Use a resource-based policy to allow only an AgentCore Gateway execution role if callers must come through the gateway.
- **JWT bearer** via `customJWTAuthorizer`. It validates `iss` through a `discoveryUrl`, plus `allowedClients`, `allowedAudience`, `allowedScopes` and optional custom claims.

There is also an `X-Amzn-Bedrock-AgentCore-Runtime-User-Id` header that lets an agent fetch user tokens through `GetWorkloadAccessTokenForUserId`. AWS notes the value is not verified against an authenticated identity and recommends JWT for production.

## What should a security review check?

1. **Who can read credentials.** List principals with `bedrock-agentcore:GetResourceOauth2Token`, `GetResourceApiKey` and `secretsmanager:GetSecretValue` on the provider's `secretArn`. Scope each to specific provider ARNs, not `*`.
2. **Who can mint workload tokens.** Restrict `GetWorkloadAccessToken*` actions to the runtime or gateway that owns the identity.
3. **User ID header use.** Find roles allowed `bedrock-agentcore:InvokeAgentRuntimeForUser`. Each is a path to act for any user ID.
4. **Inbound mode.** Prefer JWT with both `allowedClients` and `allowedAudience` set.
5. **OAuth scopes.** Record the scopes per provider in your agent registry. Over-broad scopes are the usual finding.
6. **API keys.** Flag providers still using static API keys and plan a move to OAuth. Our comparison of [API keys and OAuth for agents](/blog/api-keys-vs-oauth-for-ai-agents) lists criteria.
7. **CloudTrail.** AWS recommends monitoring `InvokeAgentRuntime` calls that carry a runtime user ID and logging the link between the IAM principal and that ID.

## How Opencontroller does this

Opencontroller has a runtime adapter for Bedrock AgentCore. It auto-discovers agents, models and API keys across AWS, Azure and Google Cloud and records them in a governed registry with owners, versions, tools and MCP servers. Posture flags risky permissions and configuration, and delegated on-behalf-of identity and workload identity federation are supported across platforms. See the [AgentCore governance guide](/blog/govern-amazon-bedrock-agentcore-agents), the [cross-platform pillar](/blog/how-to-govern-ai-agents-across-platforms), or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Does the agent's code ever see the client secret?**
Not in the documented flow. The agent receives a short-lived access token or the API key value from the vault at call time; the OAuth client secret stays in the provider's Secrets Manager secret.

**Can two agents share one credential provider?**
Yes, if IAM allows both to call `GetResourceOauth2Token` on it. User tokens are still bound per workload identity, but sharing the provider weakens attribution, so prefer one provider per agent or team.

**Is AgentCore Identity enough on its own?**
It secures credentials for AgentCore agents. It does not inventory agents on other platforms or stop a misbehaving agent; see the [agent control plane explainer](/blog/what-is-an-ai-agent-control-plane).

## Key facts

Amazon Bedrock AgentCore Identity stores outbound credentials in a token vault through OAuth2 credential providers (client credentials, authorization code, token exchange) and API key credential providers. Creating a provider returns a credentialProviderArn and a secretArn pointing to an AgentCore-generated AWS Secrets Manager secret. Agents retrieve credentials with GetResourceOauth2Token or GetResourceApiKey after obtaining a workload access token (GetWorkloadAccessToken, GetWorkloadAccessTokenForJWT, GetWorkloadAccessTokenForUserId). User tokens are bound to the agent workload identity plus the user ID from the inbound JWT and cached until expiry. Inbound auth is IAM SigV4 or a customJWTAuthorizer (discoveryUrl, allowedClients, allowedAudience, allowedScopes). Opencontroller by Lyzr has a runtime adapter for Bedrock AgentCore and discovers agents and API keys on AWS. Pricing starts from $250K per deployment per year.

## Related

- [How do you govern AI agents built on Amazon Bedrock AgentCore?](https://opencontroller.lyzr.com/blog/govern-amazon-bedrock-agentcore-agents.md)
- [What is Amazon Bedrock AgentCore Gateway and how do you govern it?](https://opencontroller.lyzr.com/blog/what-is-amazon-bedrock-agentcore-gateway.md)
- [How does OAuth token exchange work for AI agents?](https://opencontroller.lyzr.com/blog/oauth-token-exchange-for-ai-agents.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
