Setting Up AgentCore Identity - Consent Portal
AgentCore Identity - Consent Portal is a managed portal that handles user authentication and OAuth2 consent so your AI Agent can access third-party services on a user's behalf - no auth infrastructure to build or maintain.
This guide walks you through creating an AgentCore Identity Consent Portal end-to-end using the AWS Console. The Consent Portal is a hosted, AWS-managed portal that authenticates your end users to an OpenID Connect (OIDC) identity provider (IdP) and gathers their consent before your agent accesses a downstream resource on their behalf.
Preview of the Consent Portal:

Sample Architecture Diagram: In this blog post, we'll only focus on setting up Cognito, AgentCore Gateway and AgentCore Consent Portal.

Overview
The setup involves four main steps:
- Create a Cognito App Client (Inbound Auth) with Authorization Code Grant
- Create an AgentCore Gateway with Cognito JWT authorizer as the inbound authorizer
- Create an AgentCore Identity Outbound Auth (OAuth2 Credential Provider) pointing to the Cognito App Client
- Create the AgentCore Identity Consent Portal and register the callback URL in Cognito
Prerequisites
Before you begin, make sure you have:
- An AWS account with permissions to create Amazon Cognito User Pools, AgentCore Gateways, and AgentCore Identity resources.
- An existing Amazon Cognito User Pool (or access to create one). Note your User Pool ID and the AWS Region.
- At least one active test user in the User Pool who you can sign in as.
Tip: The Consent Portal requires an OIDC identity provider that issues JWT access tokens and publishes an OIDC discovery document. You may use Cognito or other providers.
Step 1 - Create a Cognito App Client (Inbound Auth)
The Consent Portal's primary IdP must use an Authorization Code Grant flow with a client secret. You will configure this in your Cognito User Pool.
- Open the Amazon Cognito console .
- Choose User Pools and select your User Pool.
- Go to the App integration tab, scroll to App clients and analytics, and choose Create app client.
- Configure the app client:
- App type: Select Traditional Web Appplication.
- App client name: Enter a name, for example
agentcore-inbound-client.
- Client secret: Ensure Generate a client secret is selected. You will need this secret later.
- Authentication flows: Make sure ALLOW_USER_PASSWORD_AUTH or similar is enabled as needed.
- Under Logins Pages > Edit Managed Login Pages Configuration:
- For Allowed callback URLs, enter a placeholder URL for now (for example,
https://placeholder.example.com/callback). You will update this with the real portal URL after the Consent Portal is created.
- Scroll down to OAuth 2.0 grant types, select Authorization code grant.
- Under OpenID Connect scopes, select:
openid,email,profile.
- Choose Save Changes.
- Note the following values - you will need them in later steps:
- User Pool ID (for example,
us-east-1_xxxxxxxxx)
- App client ID
- App client secret (choose Show client secret to reveal it)
Important: Leave the allowed callback URL as a placeholder for now. A trailing slash in the callback URL will cause authentication to fail, so enter the final URL exactly - without a trailing slash - once you have the portal URL.
Step 2 - Create an AgentCore Gateway with Cognito JWT Inbound Auth
The Consent Portal attaches to exactly one AgentCore Gateway. The Gateway must use JWT as its inbound authentication type, pointing to the same Cognito User Pool you configured above.
2a - Create the Gateway
- Open the Amazon Bedrock AgentCore console .
- In the left navigation pane, choose Gateways.
- Choose Create Gateway.
- Fill in the gateway details:
- Gateway name: Enter a name, for example
my-agentcore-gateway.
- Description: (Optional) Add a description.
- Under Inbound authentication, choose Use JSON Web Tokens (JWT).
- Configure the JWT authorizer using existing Identity Provider configurations:
- Copy the Discovery URL from Cognito eg.
https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxx/.well-known/openid-configuration
- Allowed Clients: Check it and enter the App client ID you created in the previous step.
- Choose Create Gateway.
- Wait for the Gateway status to become Active, then note the Gateway ARN - you will use this when creating the Consent Portal.
2b - Add Gateway Targets
Gateway targets define the downstream services your agent can access on behalf of users. Each target appears as a connection card on the Consent Portal for users to authorise. Add at least one target - for example, Slack or GitHub MCP servers - so the portal has connections to display.
Note: You can also add additional targets after the Consent Portal is created.
Step 3 - Create an AgentCore Identity Outbound Auth (OAuth2 Credential Provider)
The Consent Portal needs an OAuth2 Credential Provider that references the same Cognito app client. This provider is used as the primary IdP credential configuration for the portal.
- In the Amazon Bedrock AgentCore console , go to Identity in the left navigation pane.
- Choose Credential providers, then choose Create credential provider.
- Configure the credential provider:
- Name: Enter a name, for example
cognito-outbound-auth.
- Credential provider type: Select Included Provider > Cognito.
- Enter the OAuth2 configuration using values from your Cognito app client (Step 1):
- Client ID: Paste the App client ID.
- Client secret: Paste the App client secret.
- Issuer/Authorization endpoint/Token endpoint: Refer to OpenID Connect configuration URL in Cognito.
- Scopes: Enter
openid email profile
- Choose Create credential provider.
- Once created, note the Credential Provider ARN - you will use this in the next step.
Step 4 - Create the AgentCore Identity Consent Portal
With the Gateway (Step 2) and Outbound Auth Credential Provider (Step 3) in place, you can now create the Consent Portal.
- In the Amazon Bedrock AgentCore console , go to Gateways in the left navigation pane.
- Choose the gateway you created in Step 2.
- On the gateway details page, choose Create Consent Portal.
- In the Consent portal details section:
- Gateway: Confirm the correct gateway is selected.
- Consent portal name: (Optional) Adjust the generated name as needed.
- Description: (Optional) Add a description.
- In the IdP credential configurations section:
- IdP credential provider: Select the OAuth2 credential provider you created in Step 3.
- Scopes: (Optional) Add any additional scopes beyond the defaults.
- Audiences: (Optional) Add any additional audiences.
- In the Permissions section, configure the IAM execution role:
- Choose Create default role to let the console create a role with the required permissions automatically.
- Choose Create Portal.
- Wait until the Consent Portal status is ACTIVE. This may take a couple of minutes.
- Once ACTIVE, the Consent portal URL (
<portalUrl>) appears on the portal details page. Copy this URL - you need it for the next step.
Step 5 - Register the Callback URL in Cognito
After the Consent Portal is active, you must register its callback URL in your Cognito app client. Without this, Cognito will reject the authentication redirect.
- Open the Amazon Cognito console .
- Go to your User Pool → App integration tab → App clients and analytics.
- Choose the app client you created in Step 1 (
agentcore-inbound-client).
- Choose Edit on the Managed Login Pages Configuration section
- Under Allowed callback URLs, remove the placeholder URL you entered earlier and add the real callback URL: eg.
https://abc123.consent-portal.bedrock-agentcore.us-east-1.amazonaws.com/callback> ⚠️ No trailing slash. Enter the URL exactly as shown above. A trailing slash will cause the IdP to reject the callback as unregistered during authentication. Amazon Cognito calls this field Allowed callback URLs; other IdPs may label it differently (for example, Okta calls it Sign-in redirect URIs).
- Choose Save changes.
Step 6 - Verify the Portal
- Open the Consent Portal's
<portalUrl>in a browser.
- Sign in using an active user's credentials from your Cognito User Pool.
- A successful sign-in takes you to the Consent Portal page.
Note: If the portal's gateway has no targets configured yet, the Consent Portal page will appear empty. To display connections, add targets to the Gateway by following Configure a consent portal target .





Summary
You have connected a Cognito User Pool to an AgentCore Gateway and spun up a hosted Consent Portal that authenticates users and captures their authorisation before the agent touches any downstream service. From here, you can add more Gateway targets (such as Slack, GitHub, or any OAuth2-protected MCP server) to expand what your agent can act on, and integrate the portal URL into your agent's front-end to trigger the consent flow at runtime.
References
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article