Credential vending
The agent should act as the actual user, not as a shared account
A JWT-to-PAT exchange for Snowflake: short-lived, role-scoped, auto-rotating.
Kevin Keller ยท kevinkeller.org
Why it matters
Governance depends on who is calling
- Row access, masking and audit all depend on the executing user
- A shared service account makes every query look the same
- Per-user data governance is lost
- The goal: SQL runs as the human, who never logs into Snowflake directly
Why it's hard
No obvious method fits a headless agent
| Method | Problem for agents |
|---|---|
| Username and password | MFA, unsafe to automate |
| Key-pair | Tied to one user, doesn't scale |
| OAuth browser flow | Agents are headless |
| OAuth refresh tokens | Rotate on every use |
| PATs | Good fit, but how to get one without a browser? |
The exchange
From identity provider to MCP in four steps
- The user's IdP issues a JWT
- Snowflake External OAuth turns the JWT into a session
- The session creates or rotates a one-day PAT, restricted to one role
- The agent sends the PAT as a Bearer token to the MCP server
The key constraint
PATs cannot mint PATs.
Every create, rotate and remove needs JWT or OAuth authentication. A leaked PAT cannot be used to issue more.
Lifecycle
One PAT per user, one standard name
MCP_PATavoids the 15-PATs-per-user limit- No PAT yet: create with
DAYS_TO_EXPIRY=1 - PAT exists: rotate, old secret dead at once
- Expired rotated tokens: cleaned up automatically
- Every call to
exchange_token()returns a valid secret
What you get
Ephemeral credentials from existing identity
- Your IdP: Entra ID, Okta or whatever you already use
- Short-lived: a leaked PAT is useless tomorrow
- Least privilege: OAuth-derived PATs must be role-restricted
- Auditable: every creation and rotation in
QUERY_HISTORY
Which pattern when
Match the credential to the workload
| Pattern | Best for | User interaction |
|---|---|---|
| OAuth + continuous refresh | Dashboards, ETL | Once, in a browser |
| JWT to PAT exchange | Agents, headless automation | Never |
| Static PAT | Quick tests, dev | Once, in the UI |
Today's recommended path
External OAuth now works directly with MCP
External OAuth tokens work directly with Snowflake's managed MCP servers, no PAT exchange needed.
The exchange still shows the mechanics of credential vending: token exchange, scope attenuation, lifecycle and audit.
Takeaway
Derive agent credentials from the user's identity: short-lived, scoped, rotated.
Educational proof of technology