{"slug": "secure-oauth-patterns-for-snowflake-cortex-ai-through-amazon-bedrock-agentcore", "title": "Secure OAuth patterns for Snowflake Cortex AI through Amazon Bedrock AgentCore", "summary": "Amazon Bedrock AgentCore Identity now supports three tested OAuth configurations for AI agents calling the Snowflake-managed MCP server through the Model Context Protocol: Snowflake OAuth with per-user authentication and no external identity provider, three-legged OAuth through a third-party identity provider using corporate single sign-on, and two-legged OAuth with a shared service user via the client_credentials grant. Amazon Bedrock AgentCore Identity also supports an on-behalf-of (OBO) grant (TOKEN_EXCHANGE) that delivers per-user identity for unattended workloads without a consent prompt, and it acts as the credential broker, owning the token vault, refresh, and user-to-token binding while the AgentCore Gateway aggregates MCP targets into a single tools/list catalog.", "body_md": "## [Artificial Intelligence](https://aws.amazon.com/blogs/machine-learning/)\n\n# Secure OAuth patterns for Snowflake Cortex AI through Amazon Bedrock AgentCore\n\nEnterprises today need a clear way to extend their authentication and authorization controls into the agentic layer, often requiring either broad service account permissions or custom-built auth integrations that add operational overhead. When an AI agent running on [Amazon Bedrock AgentCore](https://aws.amazon.com/bedrock/agentcore/) (a platform to build, connect, and optimize agents at scale, with any framework or model) needs to call the [Snowflake-managed MCP server](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-mcp) (which exposes [Snowflake Cortex Agents](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents) as one of its tool types) through the [Model Context Protocol](https://modelcontextprotocol.io/) (MCP), the first question enterprises must answer is: how does the agent authenticate? In this post, we walk through three Open Authorization (OAuth) configurations we tested on [Amazon Bedrock AgentCore Identity](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/identity.html), a capability of Amazon Bedrock AgentCore: Snowflake OAuth (per-user, no external Identity Provider, or IdP), three-legged OAuth with a third-party Identity Provider (corporate single sign-on, or SSO), and two-legged OAuth with a third-party Identity Provider (shared service user). Amazon Bedrock AgentCore Identity also supports an on-behalf-of (OBO) grant (TOKEN_EXCHANGE) that delivers per-user identity for unattended workloads without a consent prompt. We focus on the three configurations we tested end-to-end, flagging where OBO fits as we go. By the end, you will be able to identify which pattern suits your enterprise scenario.\n\n## Solution overview\n\n[Amazon Bedrock AgentCore Gateway](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway.html), a capability of Amazon Bedrock AgentCore, connects AI agents to external tool providers through MCP server targets. It targets the Snowflake-managed MCP server, which surfaces Cortex Search and Cortex Analyst as MCP tools that an MCP-aware client can discover and invoke. Rather than acting as a wrapper, the Gateway aggregates the capabilities of its configured targets into a single unified catalog, which it presents to the agent as one tools/list response.\n\nThe core focus of this post is the [outbound authentication](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-outbound-auth.html) for Amazon Bedrock AgentCore Gateway: how it obtains and presents OAuth tokens to the Snowflake-managed MCP server. Amazon Bedrock AgentCore Identity acts as the credential broker: the Gateway obtains a workload token by calling GetWorkloadAccessTokenForJWT (because the Gateway uses JSON Web Token (JWT) inbound authentication), then calls GetResourceOauth2Token against the configured provider. AgentCore Identity owns the token vault, the token refresh, and the user-to-token binding, and it fetches, caches, and refreshes tokens automatically.\n\nAmazon Bedrock AgentCore Identity supports three OAuth configurations spanning two grant types (authorization_code and client_credentials):\n\n1. [Snowflake OAuth](https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview) : Snowflake acts as its own OAuth authorization server. Each user authenticates directly to Snowflake through the Authorization Code grant (3LO). No external identity provider is needed.\n2. Three-legged OAuth using a third-party Identity Provider: Users authenticate through corporate SSO with the Authorization Code grant. Snowflake trusts IdP-issued JSON Web Tokens (JWTs) through its [External OAuth](https://docs.snowflake.com/en/user-guide/oauth-ext-overview) security integration.\n3. Two-legged OAuth pattern using a third-party IdP: A shared service user authenticates through the client_credentials grant of the IdP. No user interaction or consent is required, which is ideal for machine-to-machine workloads.\n\nAmazon Bedrock AgentCore Identity also offers an API-key credential provider (which supports Snowflake Programmatic Access Tokens). We focus on OAuth here for per-user attribution and automatic token refresh. Each configuration uses a credential provider in Amazon Bedrock AgentCore Identity (CustomOauth2, OktaOauth2, or MicrosoftOauth2) and a corresponding security integration on the Snowflake side.\n\n**Note:** We tested these patterns with the Snowflake-managed MCP server using Okta and Microsoft Entra ID. Patterns 2 and 3 (external IdP) follow standard OAuth flows, so they can extend to other OAuth-protected MCP servers, but validate the token claims, scopes, and audience settings for your SaaS provider. Only Pattern 1 is Snowflake-specific, because it relies on Snowflake’s built-in OAuth authorization server. The Snowflake-specific elements are the OAUTH_AUTHORIZATION_SERVER issuer-lock parameter, the session:role: / session:scope: grammar, BLOCKED_ROLES_LIST, LOGIN_NAME / EMAIL_ADDRESS mapping, and QUERY_HISTORY attribution. If your SaaS exposes its own internal OAuth server, you configure outbound OAuth the same way as Snowflake OAuth.\n\n| **Pattern** | **OAuth grant** | **AgentCore Identity credential provider vendor** | **Snowflake security integration** | **Snowflake query identity mapping** | \n| Snowflake OAuth – 3LO | authorization_code | Custom provider (CustomOauth2) | TYPE = OAUTH, OAUTH_CLIENT = CUSTOM | The real user, with their assigned role | \n| 3LO with external IdP | authorization_code | Built-in provider (such as OktaOauth2, MicrosoftOauth2) | TYPE = EXTERNAL_OAUTH + OAUTH_AUTHORIZATION_SERVER (set with ALTER ACCOUNT / DATABASE / SCHEMA); EXTERNAL_OAUTH_TYPE = OKTA / AZURE / PING_FEDERATE / CUSTOM | The real user, with their assigned role | \n| 2LO with external IdP | client_credentials | Built-in provider (such as OktaOauth2, MicrosoftOauth2) or CustomOauth2 | TYPE = EXTERNAL_OAUTH + OAUTH_AUTHORIZATION_SERVER (set with ALTER ACCOUNT / DATABASE / SCHEMA); EXTERNAL_OAUTH_TYPE = OKTA / AZURE / PING_FEDERATE / CUSTOM | A shared Snowflake service user | \n\n**Notes:**\n\n- 2LO does not require a built-in vendor. CustomOauth2 with the CLIENT_CREDENTIALS grant can work with your choice of OAuth 2.0 authorization server.\n- When Amazon Bedrock AgentCore Gateway brokers the token (the pattern in this post), Snowflake validates it through the TYPE = EXTERNAL_OAUTH security integration. Setting OAUTH_AUTHORIZATION_SERVER (with ALTER ACCOUNT, DATABASE, or SCHEMA) is what lets direct MCP clients auto-discover your IdP through the Protected Resource Metadata endpoint, and it issuer-locks the MCP endpoint to that integration.\n- If you set OAUTH_AUTHORIZATION_SERVER to issuer-lock an MCP scope to an external IdP (Pattern 2), Snowflake OAuth tokens (Pattern 1) are rejected for MCP servers in that scope and do not fall back. If you need both patterns in one account, set this parameter per schema or database so each scope resolves to the right authorization server.\n\n## Solution architecture\n\nThe following diagram shows the solution we built and the components it uses: a user-facing AI application, a [Strands agent](https://strandsagents.com/) on [Amazon Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agents-tools-runtime.html), a capability of Amazon Bedrock AgentCore, [Amazon Bedrock](https://aws.amazon.com/bedrock/) for reasoning, with [Amazon Bedrock Guardrails](https://aws.amazon.com/bedrock/guardrails/) redacting personally identifiable information (PII) from prompts and responses, [Amazon Bedrock Knowledge Bases](https://aws.amazon.com/bedrock/knowledge-bases/), the fully managed Retrieval Augmented Generation (RAG) capability, over policy documents in [Amazon Simple Storage Service (Amazon S3)](https://aws.amazon.com/s3/), Amazon Bedrock AgentCore Gateway with the Snowflake-managed MCP server as its target, and Amazon Bedrock AgentCore Identity holding the token vault. The outbound OAuth path has the same shape in all three patterns: the Gateway resolves a token through AgentCore Identity, which obtains and renews it from an authorization server, and the Gateway then presents that token to the Snowflake-managed MCP server. What changes between the patterns is which authorization server issues the token and under which grant: Snowflake’s own built-in OAuth server, or a third-party IdP. Those differences are set out in the Pattern comparison table, and each pattern’s runtime flow has its own sequence diagram later in this post.\n\n## Pattern analysis\n\nThe following sections examine each pattern in detail: the authentication flow, configuration steps, and trade-offs to help you select the right approach for your use case.\n\n### Pattern 1: Snowflake OAuth (three-legged)\n\nThe Snowflake OAuth pattern uses a three-legged OAuth (3LO) flow to deliver per-user authentication without requiring an external identity provider. Each user authenticates to Snowflake with their own credentials, consents to a specific Snowflake role, and Amazon Bedrock AgentCore Identity caches that user’s access and refresh tokens. Every subsequent Snowflake call executes as that user, and QUERY_HISTORY records their real username. Note that per-role consent is not the default. The Snowflake-managed MCP server advertises session:role:all and falls back to DEFAULT_ROLE, so you set OAUTH_SCOPES_SUPPORTED (an account-, database-, or schema-level parameter set with ALTER) to narrow the role scope the server advertises, and restrict ALLOWED_ROLES_LIST on the integration to enforce which roles a user can consent to (PRE_AUTHORIZED_ROLES_LIST does the opposite: it lists roles that skip the consent step).\n\nWhat makes this pattern appealing is its simplicity: no external identity provider is required. Snowflake acts as both the authorization server and the resource server, exposing its own built-in OAuth endpoints (/oauth/authorize and /oauth/token-request). Setup follows a specific order, because the callback URL does not exist until the credential provider is created. The administrator first creates the CustomOauth2 credential provider in Amazon Bedrock AgentCore Identity with placeholder client credentials and records the callbackUrl that AgentCore Identity returns. That callbackUrl is then registered as the redirect URI on a Snowflake security integration created with TYPE = OAUTH and OAUTH_CLIENT = CUSTOM. Finally, the administrator updates the credential provider with the real client ID and secret issued by Snowflake and configures the provider’s oauthDiscovery with explicit authorization server metadata: the issuer (the Snowflake account URL), the authorization endpoint (/oauth/authorize), and the token endpoint (/oauth/token-request).\n\nThe following screenshot shows the configuration steps for credential provider vendors in Amazon Bedrock AgentCore Identity with Snowflake OAuth (3LO) settings.\n\nNext, the Amazon Bedrock AgentCore Gateway configuration points to the Snowflake-managed MCP server endpoint and references the custom Snowflake OAuth for outbound authentication.\n\nThe following sequence diagram shows the runtime authorization flow for the Snowflake OAuth pattern.\n\nThe [Snowflake OAuth authorization flow](https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview#snowflake-oauth-authorization-flow) works as follows:\n\n1. When a tool call requires a Snowflake token, Amazon Bedrock AgentCore Gateway obtains a workload token by calling GetWorkloadAccessTokenForJWT and calls GetResourceOauth2Token to check the token vault of Amazon Bedrock AgentCore Identity for the user. If no token is cached, the Gateway returns a JSON-RPC error code [-32042](https://aws.amazon.com/blogs/machine-learning/connecting-mcp-servers-to-amazon-bedrock-agentcore-gateway-using-authorization-code-flow/) carrying a URL elicitation. That authorization URL belongs to AgentCore Identity and is`session-URI-bound` . The client opens that URL in the user’s browser, which is routed to Snowflake’s bu", "url": "https://wpnews.pro/news/secure-oauth-patterns-for-snowflake-cortex-ai-through-amazon-bedrock-agentcore", "canonical_source": "https://aws.amazon.com/blogs/machine-learning/secure-oauth-patterns-for-snowflake-cortex-ai-through-amazon-bedrock-agentcore/", "published_at": "2026-11-17 20:25:23+00:00", "updated_at": "2026-11-17 21:13:24.252157+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "artificial-intelligence"], "entities": ["Amazon Bedrock AgentCore", "Snowflake", "Snowflake Cortex Agents", "Amazon Bedrock AgentCore Identity", "Amazon Bedrock AgentCore Gateway", "Model Context Protocol"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/secure-oauth-patterns-for-snowflake-cortex-ai-through-amazon-bedrock-agentcore", "markdown": "https://wpnews.pro/news/secure-oauth-patterns-for-snowflake-cortex-ai-through-amazon-bedrock-agentcore.md", "text": "https://wpnews.pro/news/secure-oauth-patterns-for-snowflake-cortex-ai-through-amazon-bedrock-agentcore.txt", "jsonld": "https://wpnews.pro/news/secure-oauth-patterns-for-snowflake-cortex-ai-through-amazon-bedrock-agentcore.jsonld"}}