ServiceNow Token Exchange via AgentCore Gateway
A new architectural configuration enables AI agents to call enterprise APIs while preserving the calling user's identity through native token exchange.

Maintaining User Identity in Enterprise AI Workflows
When artificial intelligence agents interact with enterprise APIs on behalf of users, maintaining user identity throughout the request chain is critical. Without identity propagation, API calls arrive at downstream services as the application itself rather than the individual user who initiated the action. This architectural gap can break audit trails, bypass user-level access controls, and violate the core principle of least privilege.
To address this challenge, developers can utilize tools provided within the Amazon Bedrock AgentCore documentation to build, connect, and optimize scalable agents using any framework or model. By implementing specific configuration patterns, enterprises can ensure that downstream services receive accurate user context.

Configuring AgentCore Gateway for Token Exchange
A recent technical guidance outlines how to configure AgentCore Gateway for an on-behalf-of token exchange with Microsoft Entra ID. This setup enables an AI agent to seamlessly call the ServiceNow REST API while preserving the calling user's identity. Rather than relying on custom code or an interceptor Lambda function, the gateway performs the token exchange natively on each request.
In production environments, organizations can also pair this identity propagation pattern with Amazon Bedrock Guardrails to filter harmful content and validate both agent inputs and outputs. The underlying architecture involves an AI agent application protected by Microsoft Entra ID, a Model Context Protocol server implemented via the gateway, and the ServiceNow REST API configured with an inbound OAuth integration.

Bridging Token Audiences via the OBO Flow
The operational mechanics rely on the OAuth on-behalf-of flow to bridge the gap between different token audiences. When an agent calls the gateway, it presents a JSON Web Token with an audience claim matching its own client ID. However, downstream services such as the ServiceNow REST API expect a token with an audience claim matching their own specific API connector client ID.
To resolve this, AgentCore Gateway transmits the inbound token to the Microsoft identity platform token endpoint alongside the agent application's client credentials, target scope, and the requested_token_use parameter set to on_behalf_of. Once Microsoft Entra ID validates that the user consented to the delegation, it issues a new token for the ServiceNow API with the original user claims intact.

Prerequisites and Microsoft Entra ID Setup
Implementing this solution requires an AWS account with access to the gateway, a Microsoft Entra ID tenant, and a ServiceNow instance. Administrators must ensure their account holds at least the Application Developer role to properly manage application registrations within Entra ID.
Administrators begin by creating separate application registrations for the ServiceNow API connector and the AI agent itself. For developers wishing to test the integration, a ServiceNow personal developer instance can be acquired directly through the ServiceNow developer portal.

ServiceNow Inbound Integration and OAuth Configuration
Within the ServiceNow administrative console, operators navigate to System OAuth and Inbound Integrations to establish a new third-party ID token integration supported by an OIDC identity provider. Developers must map the appropriate user claims—such as mapping the Entra preferred_username claim to the email field in ServiceNow—to ensure accurate permission mapping during API requests.
Furthermore, administrators can configure auth scopes and limit access exclusively to the Table API or other required ServiceNow endpoints. This ensures that the AI agent operates strictly within its designated boundaries while fully maintaining the original user's identity and security context throughout the request lifecycle.
Sources
- AWS Machine Learning BlogServiceNow on-behalf-of token exchange with Bedrock AgentCore Gateway
Continue chronologically





