{"slug": "servicenow-on-behalf-of-token-exchange-with-bedrock-agentcore-gateway", "title": "ServiceNow on-behalf-of token exchange with Bedrock AgentCore Gateway", "summary": "Amazon Web Services detailed how Amazon Bedrock AgentCore Gateway can perform an on-behalf-of (OBO) token exchange with Microsoft Entra ID so an AI agent can call the ServiceNow REST API while preserving the calling user's identity. In the flow, the agent presents a JWT scoped to its own Entra application registration, and AgentCore Gateway sends that token to the Entra token endpoint with the agent's client credentials, the target scope, and the parameter requested_token_use: on_behalf_of; Entra then issues a new token scoped to the ServiceNow API connector, whose preferred_username claim maps to an existing ServiceNow user so that user's permissions apply. The pattern matters because without identity propagation, API calls reach downstream services as the application rather than the user, breaking audit trails and bypassing user-level access controls.", "body_md": "## [Artificial Intelligence](https://aws.amazon.com/blogs/machine-learning/)\n\n# ServiceNow on-behalf-of token exchange with Bedrock AgentCore Gateway\n\nAI agents that interact with enterprise APIs on behalf of users need to maintain user identity throughout the request chain. Without identity propagation, API calls arrive at downstream services as the application itself rather than the user who initiated the action. This breaks audit trails, bypasses user-level access controls, and violates the principle of least privilege.\n\nAmazon Bedrock AgentCore is a platform to build, connect, and optimize agents at scale, with any framework or model. This post shows how to configure [AgentCore Gateway](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway.html), a capability of Amazon Bedrock AgentCore, for an on-behalf-of (OBO) token exchange with Microsoft Entra ID. An AI agent can then call the [ServiceNow REST API](https://www.servicenow.com/docs/r/api-reference/rest-apis/api-rest.html) while preserving the calling user’s identity. You configure the token exchange on the gateway target, and AgentCore Gateway performs the exchange on each request. The pattern can be applied to other REST APIs protected by OAuth.\n\nIn production, you can additionally pair identity propagation with Amazon Bedrock Guardrails to filter harmful content and validate the agent’s inputs and outputs.\n\n## Solution overview\n\nThe architecture involves three key components connected through AgentCore Gateway:\n\n1. An AI agent application, protected by Microsoft Entra ID through an OAuth application registration.\n2. A Model Context Protocol (MCP) server, implemented using AgentCore Gateway, sitting between the agent and ServiceNow.\n3. The ServiceNow REST API, configured with an inbound OAuth integration tied to Microsoft Entra ID.\n\nThe following figure shows the end-to-end solution architecture, including components within AWS, Microsoft Entra ID, and ServiceNow.\n\nAs shown in Figure 1, the user acquires a JSON Web Token (JWT) to invoke the agent 1. The agent authenticates to the gateway with a JWT token scoped to the agent’s own application registration 2. The gateway then exchanges that token, using the OBO flow, for a new token scoped to the ServiceNow API connector, with the original user’s identity preserved 3. ServiceNow receives a valid token whose `preferred_username` claim maps to an existing ServiceNow user and applies that user’s permissions to the API call 4.\n\n## How OBO token exchange works in this context\n\nWhen the agent calls the gateway, it presents a JWT with an `audience` claim matching the agent’s client ID (for example, `3ff88e17-XXXX-XXXX-XXXX-XXXXXXXXXXXX`). ServiceNow, however, expects a token with an `audience` claim matching its own API connector client ID (`5d4a7a11-XXXX-XXXX-XXXX-XXXXXXXXXXXX`).\n\nThe OBO flow bridges this gap. AgentCore Gateway sends the inbound token to the Entra token endpoint along with the agent application’s client credentials, the target scope, and a parameter `requested_token_use: on_behalf_of`. Entra validates that the calling user consented to the delegation, then issues a new token for the ServiceNow API with the original user’s claims intact.\n\n## Prerequisites\n\nBefore you begin, you need the following:\n\n- An AWS account with access to AgentCore Gateway.\n- A Microsoft Entra ID tenant with permissions to create [application registrations](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app) . Your account needs at least the[Application Developer role](https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/permissions-reference#application-developer) to register applications.\n- A ServiceNow instance with administrative access to configure inbound OAuth integrations. You can create a ServiceNow personal developer instance (PDI) at the ServiceNow personal developer instance signup page [https://developer.servicenow.com/](https://developer.servicenow.com/) .\n- Two Entra application registrations: one representing the AI agent, and one representing the ServiceNow API connector.\n\n## Configuring Microsoft Entra ID\n\nStart by creating an application registration to represent the ServiceNow API connector. The following screenshot shows the application registration page for the ServiceNow API Connector in Microsoft Entra ID.\n\nAfter creating, in the Overview page note the **Application (client) ID.**\n\nIn the navigation menu expand **Manage** and select **Expose an API** and add a scope named `user_impersonation` using the default Application ID URI. This scope is what the OBO flow requests when exchanging tokens. The following screenshot shows how to expose an API in Microsoft Entra ID.\n\nNext, create an application registration for the AI agent. The following screenshot shows the application registration page in Microsoft Entra ID for the ServiceNow Agent application.\n\nNote the Application (client) ID for the ServiceNowAgent.\n\nCreate a client secret on this registration. The gateway needs these credentials to perform the OBO exchange. The following screenshot shows how you can create a client secret on the ServiceNow Agent application registration in Microsoft Entra ID.\n\nThen configure the agent application to have API permissions to call the ServiceNow API connector application. The following screenshot shows the API permissions that you need to configure on the ServiceNow Agent application registration in Microsoft Entra ID.\n\nNo changes to the Entra configuration are needed beyond what you would set up for any standard OBO integration between two applications.\n\n## Configuring ServiceNow\n\nIn the ServiceNow administrative console, navigate to **System OAuth > Inbound Integrations** and create a new inbound integration (Third party ID token issued by OIDC supporting identity provider). Specify the client ID from the ServiceNow API connector application registration you created in Entra. The following screenshot shows the configuration of the inbound integration in ServiceNow.\n\nIn the same screen, create a new OpenID Connect (OIDC) provider configuration and enter the OIDC metadata URL for your Entra tenant. Map the user claim to the appropriate user field. For example, if your Entra tenant places the user’s email in the `preferred_username` claim, map that to the **Email** field in ServiceNow. Clear JTI verification if your Entra tenant doesn’t include it in tokens. Entra uses an internal claim named `uti` on tokens it issues, which is equivalent to JTI. Consider mapping this `uti` claim to a `jti` claim to provide additional replay protection and denylisting. The following screenshot shows how to configure the OIDC provider in ServiceNow.\n\nFinally, in the same screen, create an auth scope for the integration (for example, `APIConnector`). The following screenshot shows how to create a new auth scope in ServiceNow.\n\nLimit the auth scope to the Table API, or whichever ServiceNow APIs your agent needs to access, as shown in the following screenshot.\n\nAfter this configuration is complete, ServiceNow accepts authorization tokens with an `audience` of your API connector’s client ID and resolves the calling user from the `preferred_username` claim.\n\n## Configuring AgentCore Gateway\n\nWith Entra and ServiceNow configured, you can now set up AgentCore Gateway to handle the OBO exchange natively.\n\n### Step 1: Create an outbound auth configuration\n\nCreate a new outbound auth configuration (choose **Build > Identity > Add Outbound Auth > Add OAuth client**) in AgentCore and select **Customized provider**. Enter the client ID and client secret from your agent application registration, along with the Entra discovery URL as shown in the following screenshot.\n\nExpand **Additional configurations** and select **JWT authorization grant** as shown in the following screenshot. This tells the gateway to use a JWT-based grant type for token exchange.\n\n### Step 2: Create the gateway with MCP version 2025-11-25\n\nCreate a new AgentCore Gateway (**Build > Gateways > Create gateway**). When defining the gateway details, expand **Additional configurations — optional** and select MCP version **2025-11-25** as shown in the following screenshot. This version is required for native OBO support. You can’t turn on native OBO for gateways created with earlier MCP versions.\n\nConfigure the inbound identity using your agent’s application registration (select **Use existing identity provider configurations**), as you would for any gateway that accepts Entra-authenticated requests.\n\nUnder **JWT Authorization Configuration** add the Application ID we documented earlier for the **ServiceNowAgent** as shown in the following screenshot.\n\n### Step 3: Add a target with token exchange\n\nAdd a target to the gateway pointing to your ServiceNow REST endpoint. Define the schema inline. For example, to expose a tool called ListIncidents that calls the ServiceNow Table API, you can use the following OpenAPI specification (replace the server URL with that for your PDI).", "url": "https://wpnews.pro/news/servicenow-on-behalf-of-token-exchange-with-bedrock-agentcore-gateway", "canonical_source": "https://aws.amazon.com/blogs/machine-learning/servicenow-on-behalf-of-token-exchange-with-bedrock-agentcore-gateway/", "published_at": "2026-11-03 16:47:40+00:00", "updated_at": "2026-11-03 16:49:51.446192+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "artificial-intelligence"], "entities": ["Amazon Web Services", "Amazon Bedrock AgentCore", "AgentCore Gateway", "ServiceNow", "Microsoft Entra ID", "ServiceNow REST API"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/servicenow-on-behalf-of-token-exchange-with-bedrock-agentcore-gateway", "markdown": "https://wpnews.pro/news/servicenow-on-behalf-of-token-exchange-with-bedrock-agentcore-gateway.md", "text": "https://wpnews.pro/news/servicenow-on-behalf-of-token-exchange-with-bedrock-agentcore-gateway.txt", "jsonld": "https://wpnews.pro/news/servicenow-on-behalf-of-token-exchange-with-bedrock-agentcore-gateway.jsonld"}}