Secure OAuth patterns for Snowflake Cortex AI through Amazon Bedrock AgentCore
In one sentence
This post explains how to configure three secure OAuth authentication patterns using Amazon Bedrock AgentCore Identity for AI agents calling Snowflake Cortex AI via MCP.
Key points
- Amazon Bedrock AgentCore Gateway connects to external tools via MCP, with AgentCore Identity acting as a credential broker to manage tokens automatically.
- The post tests three OAuth patterns: Snowflake-native OAuth (3LO), three-legged OAuth with a third-party IdP, and two-legged OAuth.
- The first two patterns use the authorization code grant for per-user attribution, while the two-legged pattern suits machine-to-machine shared service accounts.
- The external IdP patterns follow standard OAuth flows (tested with Okta and Microsoft Entra ID) and can extend to other OAuth-protected MCP servers.
In depth
An AI-written overview of the original article, not the article itself.
The AWS Machine Learning Blog details three OAuth patterns tested on Amazon Bedrock AgentCore Identity for AI agents to securely access the Snowflake-managed MCP server. These patterns help enterprises extend authentication and authorization controls to the agentic layer without relying on broad service account permissions or custom integrations.
Architecture and Credential Brokering
According to the article, Amazon Bedrock AgentCore Gateway connects AI agents to external tools like Cortex Search and Cortex Analyst via the Snowflake-managed MCP server. Rather than acting as a simple wrapper, the Gateway aggregates capabilities into a unified tool catalog.
For outbound authentication, Amazon Bedrock AgentCore Identity serves as the credential broker. The Gateway obtains a workload token via GetWorkloadAccessTokenForJWT and requests an OAuth token via GetResourceOauth2Token. AgentCore Identity manages the token vault, automatic refreshes, and user-to-token bindings.
Three OAuth Patterns Compared
The post outlines three OAuth configurations across two grant types. Pattern 1 is Snowflake OAuth (three-legged OAuth), which uses the authorization_code grant with Snowflake acting as its own authorization server, requiring no external Identity Provider (IdP) and attributing queries to real users.
Pattern 2 is three-legged OAuth with an external IdP (tested with Okta and Microsoft Entra ID), enabling corporate single sign-on while still mapping queries to individual users. Pattern 3 is two-legged OAuth with an external IdP using the client_credentials grant for a shared service user, suited for unattended machine-to-machine workloads.
Snowflake OAuth Flow Details
For Snowflake OAuth, administrators must first create a CustomOauth2 provider in AgentCore Identity to obtain a callback URL, register it in Snowflake, and then update the provider with Snowflake's client credentials and endpoints.
At runtime, if no token is cached, the Gateway returns a JSON-RPC error (-32042) with an authorization URL. After the user logs in and consents to a specific role, the application calls CompleteResourceTokenAuth to bind the code and prevent hijacking before exchanging it for a token.
This summary was generated by AI from the original article and may contain errors; the original is authoritative. Copyright belongs to the original author.