Enterprise
Three OAuth patterns for Snowflake Cortex AI agents on Bedrock
AWS details how enterprises can extend authentication controls to AI agents calling Snowflake through the Model Context Protocol.
Key takeaways
- AWS documented three OAuth configurations for Amazon Bedrock AgentCore Identity when agents call Snowflake Cortex through MCP servers.
- Snowflake native OAuth delivers per-user authentication without an external IdP, with queries attributed to individual users in QUERY_HISTORY.
- Three-legged OAuth with corporate SSO lets users authenticate through existing identity providers like Okta or Entra ID while maintaining per-user attribution.
- Two-legged OAuth uses a shared service account for machine-to-machine workloads that don't require individual user consent.
- AgentCore Identity automatically handles token caching, refresh, and user-to-token binding across all three patterns.
Enterprises deploying AI agents that call external tools face a fundamental authentication challenge: how does an agent running on one platform securely authenticate to a data service on another? AWS has published technical guidance on three OAuth configurations for Amazon Bedrock AgentCore Identity when agents need to call Snowflake Cortex AI through the Model Context Protocol.
The configurations span two OAuth grant types and address different enterprise scenarios: Snowflake's native OAuth for per-user authentication without an external identity provider, three-legged OAuth with corporate single sign-on through a third-party IdP, and two-legged OAuth using a shared service account for machine-to-machine workloads.
How the architecture works
Amazon Bedrock AgentCore Gateway connects AI agents to external tool providers through MCP server targets. When the gateway needs to call the Snowflake-managed MCP server—which exposes Cortex Search and Cortex Analyst as MCP tools—it obtains OAuth tokens through Amazon Bedrock AgentCore Identity, which acts as the credential broker. AgentCore Identity owns the token vault, handles token refresh automatically, and maintains user-to-token bindings.
The gateway obtains a workload token by calling GetWorkloadAccessTokenForJWT, then calls GetResourceOauth2Token against the configured provider. AgentCore Identity fetches, caches, and refreshes tokens without application-level intervention.
Pattern one: Snowflake native OAuth
The simplest configuration uses Snowflake as both authorization server and resource server. Each user authenticates directly to Snowflake with their credentials and consents to a specific Snowflake role. AgentCore Identity caches that user's access and refresh tokens, and every subsequent query executes as that user. Snowflake's QUERY_HISTORY records their real username.
This pattern requires no external identity provider. Setup involves creating a CustomOauth2 credential provider in AgentCore Identity, registering the callback URL in a Snowflake security integration with TYPE = OAUTH and OAUTH_CLIENT = CUSTOM, then updating the provider with the client ID and secret Snowflake issues.
Access tokens are short-lived—600 seconds by default, with a 3,600-second maximum. When a token expires, AgentCore Identity automatically uses the refresh token to obtain a new one. Refresh token lifetime is controlled by OAUTH_REFRESH_TOKEN_VALIDITY, which the reference implementation sets to 86,400 seconds.
Pattern two: Three-legged OAuth with corporate SSO
This configuration combines per-user authentication with corporate identity providers like Okta or Microsoft Entra ID. Users sign in through the external IdP, which enforces multi-factor authentication and conditional access policies. The IdP-issued JWT is presented to Snowflake, which validates it through its External OAuth security integration.
Snowflake verifies the issuer, audience, and signature through a JSON Web Key Set, then maps a configurable claim to a Snowflake user's LOGIN_NAME or EMAIL_ADDRESS. The query runs as that user. No separate Snowflake passwords are required.
AgentCore Identity provides built-in credential provider vendors for popular IdPs, including OktaOauth2 and MicrosoftOauth2, which accept client credentials and IdP endpoints through standard configuration.
Pattern three: Two-legged OAuth for service accounts
The third pattern uses the client_credentials grant for machine-to-machine workloads. A shared service user authenticates through the IdP with no user interaction or consent prompt. This approach suits unattended batch processes or system integrations where individual user attribution is not required.
Snowflake validates the token through the same External OAuth integration used in pattern two, but queries execute as a single shared Snowflake service user rather than individual end users.
Why it matters
As enterprises build AI agents that orchestrate calls across multiple SaaS platforms, authentication becomes a critical control point. These patterns let organizations extend existing identity governance—role-based access, audit trails, MFA policies—into the agentic layer without building custom auth integrations or granting overly broad service account permissions. The choice between patterns depends on whether the enterprise prioritizes per-user audit trails, integration with corporate SSO, or operational simplicity for automated workloads.
These implementation details were first reported by AWS in a technical blog post on the Amazon Web Services Machine Learning Blog.