By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
An agent that calls external APIs needs credentials—GitHub tokens, Slack keys, database passwords. If you hard-code those secrets into prompts or source code, you've already lost. AgentCore Identity solves this by giving your agent a proper identity, storing secrets in an encrypted vault, and handling token exchange so your code never touches raw credentials.
Inbound: who is allowed to call your agent? Outbound: what systems is your agent allowed to access? These are separate concerns, and AgentCore handles both.
You pick one of two inbound authentication modes per runtime. AWS IAM (SigV4) lets callers sign requests with their AWS credentials. OAuth 2.0 / JWT lets callers present a bearer token from your identity provider—Cognito, Okta, Entra, or another OIDC-compliant provider. You configure the discovery URL, allowed audiences, and allowed clients.
If you need both modes, create separate runtime versions. A single runtime enforces one scheme at a time.
When you create a runtime, AgentCore automatically creates a workload identity for it. This is a first-class, non-human identity that represents the agent itself. IAM roles still govern what the agent can do in AWS; the workload identity governs what tokens it can request from the token vault.
When your agent needs to call an external service, it doesn't fetch credentials directly. Instead, it exchanges two things at the token vault: its own workload identity and the inbound user token (if the user is involved). The vault returns a workload access token, which the agent then uses to get the actual outbound token—a GitHub OAuth token, for example.
This exchange lets you enforce fine-grained policies: which agents can access which services, on behalf of which users, under what conditions.
User-delegated (3-legged OAuth): the agent acts as the end user, with that user's consent. Useful when the agent needs to post to Slack as the user, or open a pull request in their GitHub account.
Autonomous (machine-to-machine): the agent acts as itself with service-level credentials. Useful when the agent has its own GitHub bot account or database user.
You register a credential provider once with AgentCore: OAuth2 client details, an API key, or another form of credentials. AgentCore stores everything in the token vault, encrypted at rest and in transit. Your code never sees the raw secret.
Use the SDK decorator to request a token. On the first call, the user sees a consent link. After that, the vault supplies and refreshes tokens silently.
# Shape of the SDK pattern - check the Identity quickstart for your version
from bedrock_agentcore.identity import requires_access_token
@requires_access_token(
provider_name="github-provider", # the credential provider you registered
scopes=["repo"],
auth_flow="USER_FEDERATION", # user-delegated; use M2M for autonomous
)
async def list_repos(*, access_token: str):
# The decorator fetched/refreshed the token from the vault for us
return await call_github(access_token)
The decorator handles the exchange with the vault. You receive the token already bound to the user (or the agent, in autonomous mode) and ready to use.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.