{"id":"TIE-AGT-032","title":"Token vault: agents call other apps without holding people's tokens","maturity":"documented","collection":"Agent identity","category":"Credentials","complexity":"Medium","intent":"Let agents call third-party and internal APIs on a person's behalf without ever storing, seeing or passing on that person's long-lived tokens, by keeping refresh tokens in a vault or broker that issues short-lived, narrowly scoped access, or injects it at a gateway.","summary":"Agents that call Google, Slack, Salesforce or internal APIs for a person often keep that person's refresh tokens in their own storage or even in the model's context. A vault holds the tokens after consent, hands out short-lived, downscoped access or injects it at a gateway, and revokes centrally.","problems":["Token theft","Credential leakage through prompts and logs","Consent sprawl","Offboarding and revocation","Third-party SaaS access by agents","Audit of delegated access"],"standards":["OAuth 2.0 (RFC 6749)","OAuth 2.0 Token Exchange (RFC 8693)","OAuth 2.0 Security Best Current Practice (RFC 9700)","Model Context Protocol authorization (no token passthrough)","OWASP Top 10 for Agentic Applications 2026 (ASI03 Identity and Privilege Abuse)"],"tags":["token vault","token broker","credential injection","refresh token","connected accounts","brokered consent","downscoping","third-party API","SaaS","secretless agent","token passthrough","Auth0 Token Vault","API Management credential manager","Agent Gateway"],"roles":["IAM architect","Identity engineer","Security leader","Platform engineering","AI engineering"],"industries":["Cross-industry","Financial services","Healthcare","Retail","Public sector"],"builds_on":["TIE-AGT-002","TIE-AGT-014"],"related":["TIE-AGT-015","TIE-AGT-016","TIE-AGT-033"],"authors":"Trevonix Innovation","reviewers":"Trevonix IAM architecture","version":"1.0","last_reviewed":"2026-11-24","published":"2026-11-24","og_image":"og-tie-agt-032.png","sections":{"summary":[{"type":"bullets","content":"The person **consents once** per connected app; the **vault keeps the refresh token**, encrypted and bound to that person and connection.\nAt run time the agent gets a **short-lived, downscoped access token** for one connection, or better, a **gateway injects** it into the outbound call so the agent **never sees a token**.\nTokens **never enter the model's context**, every retrieval is **logged**, and revoking the person, the agent or the connection takes effect **immediately**."}],"problem":[{"type":"paragraph","content":"Useful agents act in other people's apps: reading a mailbox, posting to a chat channel, updating a CRM record, opening a ticket. Each of those apps has its own OAuth authorisation server, so the agent needs a token issued by that app for that person. The fast way to build this is to run the consent flow once and save the refresh token in the agent's database, a configuration file or the agent framework's memory.\n\nThat shortcut creates a pile of long-lived, high-value credentials in the least protected place in the architecture. Prompt injection can make an agent print or forward a token. Debug logs and traces capture tokens in tool arguments. A developer copies a refresh token into a notebook to test something. When a person leaves or withdraws consent, nobody knows which agents still hold their tokens, and there is no single place to revoke them. The MCP authorisation specification forbids passing a client's token through to downstream APIs for the same reason."},{"type":"note","content":"A refresh token is usually worth more than the person's password for the same app: it bypasses MFA and keeps working until it is revoked.","title":"Why this matters"}],"use_when":[{"type":"bullets","content":"Agents call third-party SaaS APIs (mail, calendar, chat, CRM, code hosting) for a person.\nSeveral agents or tools need the same person's access to the same app.\nYou must be able to show who consented, which agent used the access, and to revoke it quickly."}],"avoid_when":[{"type":"bullets","content":"The API trusts your own identity provider directly. Use on-behalf-of delegation (TIE-AGT-002) or enterprise-managed cross-app access (TIE-AGT-007) instead of storing third-party tokens.\nThe agent acts with its own authority and no person is involved. Use the agent's own short-lived credentials (TIE-AGT-014)."}],"forces":[{"type":"bullets","content":"**Convenience against exposure.** One stored token makes the agent easy to build and the token easy to steal.\n**Retrieval against injection.** Handing the agent a short-lived token is simple; injecting it at a gateway keeps it away from the agent entirely but needs a gateway in the path.\n**Offline work against standing access.** Background agents need access when the person is not present, which looks a lot like a standing credential.\n**Scope at consent against scope at use.** People consent to broad scopes once; each task needs far less."}],"solution":[{"type":"paragraph","content":"Put a token vault, or a broker that contains one, between agents and the apps they call. The person connects their account to the vault through the app's normal consent screen. The vault stores the refresh token encrypted, keyed by person, connection and organisation, and handles refresh and rotation. At run time the agent authenticates as itself, presents the person's context (a session or delegated token from your identity provider), and either receives a short-lived access token for one connection and the smallest set of scopes the task needs, or sends the request through a gateway that adds the credential on the way out. Tool code uses the token; the model never sees it. Revocation, audit and consent records all live in the vault."},{"type":"image","content":"The vault keeps refresh tokens; agents receive short-lived access, or a gateway injects it.","title":"Solution overview","media":"tie-agt-032-solution.png","alt":"Diagram. Left: a person connects their mail and CRM accounts through the apps' consent screens; the refresh tokens go into a token vault, encrypted and keyed by person and connection. Middle: an AI agent with its own identity and the person's delegated token. Two run-time paths. Path A, retrieval: t"},{"type":"table","content":"Approach | Agent sees a token? | Revocation | When to use\nAgent stores refresh tokens itself | Yes, long-lived | Per agent, often impossible | Never in production\nVault retrieval (token exchange) | Yes, short-lived access token only | Central | Tool code needs to call the API directly, for example through an SDK\nGateway injection | No | Central | Calls go through a gateway or MCP proxy you control\nVaulted static secret | Yes, unless injected | Central, with rotation | Legacy APIs with API keys or passwords only","title":"Options compared"},{"type":"numbered","content":"**Register each third-party app once** as a connection in the vault, with its OAuth client, allowed scopes and token endpoint.\n**Let people connect their accounts** through the app's own consent screen, initiated from your app, and show them which agents may use each connection.\n**Authenticate the agent as itself** and pass the person's context; the vault checks that this agent may use this connection for this person.\n**Downscope at use:** request only the scopes the current task needs; the vault refuses scopes the person never granted.\n**Prefer injection:** route calls through a gateway that adds the credential, so neither the agent nor the model handles tokens.\n**Keep tokens out of the model:** tools receive and use tokens in code; tool results returned to the model never contain them.\n**Log every retrieval** (person, agent, connection, scopes, time, correlation ID) and alert on unusual use.\n**Revoke centrally** when a person leaves, withdraws consent, or an agent is stopped (TIE-AGT-016); revoke at the app as well where it supports revocation.","title":"How it works"},{"type":"tip","content":"For background agents that run when the person is offline, allow vault retrieval only for connections the person marked for offline use, only for named agents, and only with scopes listed at consent time. Show the person those standing permissions and let them withdraw them.","title":"Offline agents without standing access"}],"design_rules":[{"type":"numbered","content":"**No refresh tokens outside the vault.**\n**Agents authenticate as themselves before any retrieval.** A request without the agent's own identity is refused.\n**Access tokens are short-lived and downscoped per task.**\n**Tokens never appear in prompts, tool results, traces or logs.** Redact them at the framework level.\n**One revoke switch per person, per agent and per connection.**\n**Consent records are auditable and visible to the person.**\n**Prefer injection over retrieval** wherever a gateway is in the path."}],"anti_patterns":[{"type":"table","content":"Anti-pattern | What goes wrong\nRefresh tokens in the agent's database or environment variables | One breach exposes every person's access to every connected app\nTokens passed to the model as tool context | Prompt injection prints or forwards them\nOne broad consent reused for every task | Each task carries full mailbox or CRM access\nShared service account in the SaaS app instead of per-person tokens | The app cannot tell whose request it is; audit is meaningless\nNo link between offboarding and the vault | Leavers' tokens keep working in agents for months\nToken passthrough from the client to downstream APIs | Tokens reach audiences they were never issued for"}],"benefits":[{"type":"bullets","content":"Long-lived credentials sit in one hardened place instead of in every agent.\nCentral consent, revocation and audit across agents and apps.\nSmaller blast radius: stolen tokens expire in minutes and carry few scopes.\nDevelopers stop writing OAuth refresh logic for every integration."}],"costs":[{"type":"bullets","content":"A vault or broker product, or a gateway that can inject credentials.\nPer-app connection setup and consent screens.\nChanges to agent tool code to fetch tokens on demand.\nSome apps issue only broad scopes, limiting how far downscoping can go."}],"tests":[{"type":"table","content":"Test | Expected result\nSearch agent storage, logs and traces for refresh tokens | None found\nAsk the agent (by prompt) to reveal the token it used | It cannot; no token is in its context\nAgent requests a scope the person never granted | Vault refuses\nAnother agent requests the same person's connection | Refused unless that agent is allowed for this connection\nPerson withdraws consent, then the agent retries | Retrieval fails immediately\nDisable the agent's identity | No further retrievals for any person"}],"maturity_notes":[{"type":"paragraph","content":"**Documented.** Written from vendor documentation and standards. Dedicated token vaults for agents became generally available in 2025 and 2026, and several related features (downscoping at use, offline workers) are still in early access."}],"faq":[{"type":"faq","content":"No. A secrets manager stores your organisation's secrets. A token vault stores each person's delegated tokens after their consent, refreshes them, and releases access only to agents allowed to act for that person.","title":"Is a token vault the same as a secrets manager?"},{"type":"faq","content":"Only if the person's account is the only way to reach the app. Prefer an app-level integration that trusts your identity provider (cross-app access), so the app sees both the person and the agent and no third-party refresh token is stored at all.","title":"Should we vault tokens for our own internal apps too?"}],"references":[{"type":"bullets","content":"[Auth0: Token Vault](https://auth0.com/features/token-vault)\n[Auth0: Auth0 for AI Agents is generally available](https://auth0.com/blog/auth0-for-ai-agents-generally-available/)\n[Okta Help: Agent Gateway](https://help.okta.com/oie/en-us/Content/topics/ai-agents/agent-gateway.htm)\n[Microsoft Learn: About API credentials and credential manager in Azure API Management](https://learn.microsoft.com/azure/api-management/credentials-overview)\n[RFC 8693: OAuth 2.0 Token Exchange](https://www.rfc-editor.org/rfc/rfc8693)\n[RFC 9700: Best Current Practice for OAuth 2.0 Security](https://www.rfc-editor.org/rfc/rfc9700)"}]},"recipes":{"ping":{"status":"documented","product_name":"PingGateway token mediation and PingOne Privilege","summary":"Gateway maps agent tokens to backend credentials held in secret stores; no per-person third-party token vault documented.","last_verified":"2026-11","blocks":[{"type":"paragraph","content":"Use PingGateway as the broker: agents present tokens from PingOne or Advanced Identity Cloud, and PingGateway maps them to the credential each backend expects (scoped tokens, API keys or mTLS), loading downstream secrets from its secret stores, so agents never hold backend credentials. For agent access to MCP and Git servers with just-in-time, policy-controlled credentials, PingOne Privilege offers an Agent Privilege MCP gateway. Ping does not document a per-person third-party token vault equivalent to a connected-accounts store; confirm with Ping before designing one around it."}]},"okta":{"status":"documented","product_name":"Okta for AI Agents: brokered consent, Agent Gateway and vaulted secrets","summary":"Okta brokers third-party tokens after consent and its Agent Gateway injects downstream credentials so agents never see them. Written from Okta documentation.","last_verified":"2026-11","blocks":[{"type":"numbered","content":"Add the third-party MCP server or app under **Applications and Resources > MCP Servers**, with its external authorisation server.\nOn the authorisation server card, configure **Brokered consent** so Okta brokers the third-party access token after the person consents.\nCreate a resource connection from the agent (**Directory > AI Agents >** agent **> Resource connections > Add resource connection**) to that MCP server or application.\nFor no-token-in-agent operation, put the MCP servers behind an **Agent Gateway** (**Security > Agent Gateway**); the gateway authenticates the agent with Okta tokens and injects downstream credentials.\nFor legacy APIs with static keys, use the **Secret** resource type, which retrieves a credential vaulted in Okta Privileged Access.","title":"Configure"},{"type":"bullets","content":"Brokered consent requires each person's consent before the agent can act for them.\nSecret and service account connections need the Okta Privileged Access security admin role and are early access; Okta Privileged Access is not in the Okta for AI Agents Core SKU.\nDeactivating a resource connection denies all future requests from that agent to that resource.","title":"Gotchas"}]},"entra":{"status":"documented","product_name":"Azure API Management credential manager with Microsoft Entra Agent ID","summary":"On-behalf-of for Microsoft-protected APIs; API Management stores and injects third-party SaaS tokens. Written from Microsoft documentation.","last_verified":"2026-11","blocks":[{"type":"numbered","content":"For Microsoft-protected APIs, no vault is needed: use the agent identity with on-behalf-of to obtain tokens for Microsoft Graph and your own APIs.\nFor third-party SaaS, use **Azure API Management credential manager**: in the API Management instance go to **APIs > Credential manager > Create**, register the SaaS app as an OAuth 2.0 credential provider, and create connections.\nAdd access policies so only the agent's identity (or the specific users) can use each connection.\nIn the API's inbound policy, use **get-authorization-context** to fetch the token and set the Authorization header, so the agent calls API Management and never handles the SaaS token.","title":"Configure"},{"type":"bullets","content":"API Management encrypts stored tokens and refreshes them when the access token expires.\nUser-delegated connections need the Azure API Management Data Plane service principal in the tenant; Microsoft's guide creates it with PowerShell, so make that a planned, recorded admin step.","title":"Gotchas"}]},"saviynt":{"status":"not-available","product_name":"Saviynt","summary":"No per-person token vault for agents; Saviynt governs which tools agents may reach.","last_verified":"","blocks":[]},"misc":{"status":"documented","product_name":"Auth0 Token Vault","summary":"Dedicated token vault for agents: connected accounts, token exchange, organisation isolation; downscoping and offline workers in early access.","last_verified":"2026-11","blocks":[{"type":"numbered","content":"In Auth0, create a connection for each third-party app (for example Google or Slack) and enable it for Token Vault.\nLet people link accounts through **Connected Accounts for Token Vault**.\nIn agent tool code, exchange the person's Auth0 token for a third-party access token with Token Vault's access token exchange, requesting only the scopes the tool needs.\nUse Token Vault with Organizations (GA May 2026) to keep tokens separate per customer organisation in B2B apps.","title":"Configure (Auth0 Token Vault)"},{"type":"bullets","content":"Runtime downscoping (August 2026) and the Privileged Worker flow for offline agents (July 2026) are early access; check status before relying on them.","title":"Gotchas"}]}},"slug":"tie-agt-032-token-vault-agents-call-other-apps-without-holding-people-s-tokens","updated_at":"2026-11-24T18:49:33.137Z","url":"https://exchange.trevonix.com/patterns/tie-agt-032-token-vault-agents-call-other-apps-without-holding-people-s-tokens","markdown_url":"https://exchange.trevonix.com/patterns/tie-agt-032-token-vault-agents-call-other-apps-without-holding-people-s-tokens.md","publisher":"Trevonix","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"}}