WhoBuilt

How to Secure Agents using OAuth

Jul 30, 2025· 19 min· 9.8K views·Watch on YouTube

Speaker

Jared Hanson, Keycard co-founder and creator of Passport.js, explains how OAuth can secure AI agents at the AI Engineer conference.

Replace static secrets with delegated access

Hanson says connected agents are more useful, but broad access creates security risks while limiting access can reduce business value. MCP setups often rely on long-lived, broadly scoped API keys stored in configuration files or environment variables. OAuth can replace those static secrets with dynamic access, using an authorization server to mediate consent and issue tokens.

Keep OAuth roles separate in MCP

Hanson maps the OAuth client role to an agent or chatbot and the resource server role to an MCP server. He criticizes an early MCP authorization draft for combining the resource server and authorization server in the MCP server. Later revisions separate those roles, so MCP servers mainly need to verify incoming tokens.

Give agents usable identities

Hanson says agent security will also require agent-to-agent authorization and ways to identify clients without manual registration. He views dynamic client registration as a poor fit because requests are uncredentialed and can leave agents anonymous. For public clients, he points to Client ID Metadata Documents; for verifiable clients, he proposes URL-based identities backed by public keys and signed assertions.

Authorize actions and track access chains

Hanson argues that scopes can be too coarse and long-lived for agent actions such as financial transactions. He points to Rich Authorization Requests as a way to express more specific permissions. For calls that continue from an MCP server to other APIs, he recommends examining OAuth Token Exchange and the Identity Assertion Grant to carry authorization across systems.

Handle agents that work asynchronously

Hanson says browser-based OAuth flows assume a user is present, while agents may keep working after the user leaves. He suggests considering real-time ways to request additional access, such as SMS or push notifications. He also points to SIP, XMPP, and WebRTC as prior work relevant to voice, video, and background interactions.

Takeaways

  • Replace long-lived MCP API keys with OAuth tokens that can be issued and rotated.
  • Keep authorization servers separate from MCP resource servers so each has a clear responsibility.
  • Choose an agent identity approach that fits the trust required; runtime registration can leave clients anonymous.
  • Use more specific authorization for sensitive transactions instead of relying only on broad scopes.
  • Plan how permissions and identity will carry through backend API calls and agent workflows.

Mentioned in this talk

Search inside this talk

What was claimed 9

Show all 9 facts

Related talks