Agent authentication: API keys, OAuth, and tokens

Published

AI agent authentication is the cryptographic or token mechanism an agent uses to prove a claim on an incoming request. That is distinct from agent identity: identity defines who the agent is, which human or organization owns it, and what terms or delegation apply; authentication verifies the proof presented on the wire. Most systems fail when they try to force one credential type across every stage of an agent's lifecycle. Static API keys, OAuth 2.1, SPIFFE workload credentials, and short-lived brokered assertions each solve a different boundary.

Why agentic authentication spans four mechanisms

An agent crosses multiple trust boundaries in a single task. It runs inside a coding tool or server process, connects to local or remote MCP tool servers, calls internal microservices, creates new accounts at third-party APIs, and calls those APIs over weeks of runtime work. No single credential handles both internal workload attestation and public, cross-organization onboarding without leaving a gap.

Picking the right mechanism starts with asking what already exists at the moment the request arrives. If an account, organization, and trust relationship already exist, OAuth 2.1, static keys, or workload certificates can verify the caller. When an unknown agent arrives at a public signup endpoint to create a new customer account, none of those three establishes a verified human owner or an accepted terms record.

The four agent authentication mechanisms compared

Each mechanism operates at a specific lifecycle stage and carries concrete trade-offs around human attribution, revocation, and scope.

Static API keys

A static API key is a bearer secret issued after an account exists and sent in an authorization header on runtime requests. It is simple to rotate in a single service and works well for ongoing machine-to-machine API calls once a customer record, billing tier, and rate limit are in place.

As a primary agent authentication model, static keys break down when shared across tools or pasted into prompts. A bearer key carries no per-agent identity, no human attribution beyond whoever generated it, and no cryptographic trail of accepted terms. If two agents share one key, you cannot tell which agent triggered a spike, and revoking the key breaks every workflow using it. Static keys also assume an account already exists; they do not help an agent sign up at a new service.

OAuth 2.1 and OIDC (including MCP OAuth)

OAuth 2.1 with PKCE (S256) and OpenID Connect are built for delegated authorization against an existing account or tool server. In modern MCP setups, a client registers automatically via Dynamic Client Registration (DCR) or a Client ID Metadata Document (CIMD), sends the user through browser consent, and receives short-lived access tokens plus rotating refresh tokens scoped to explicit permissions.

Agent Registrar uses this pattern for its own remote MCP endpoint at https://agentregistrar.dev/mcp: the coding tool completes OAuth 2.1 consent in the browser, binding the session to one selected agent sub-identity (agt_...) under the developer's account. That gives the harness scoped MCP tool access without copying passwords or long-lived personal tokens. What OAuth 2.1 does not do on its own is create a net-new customer account at an unconfigured third-party provider or hash-pin that provider's terms of service at signup time.

mTLS and SPIFFE/SPIRE workload credentials (X.509 and JWT SVIDs)

Inside an organization's own infrastructure, mutual TLS and SPIFFE/SPIRE workload identity authenticate services without static secrets. A local SPIRE agent attests a container or process and issues an X.509 SVID or JWT SVID tied to a SPIFFE ID within a known trust bundle.

Workload credentials are well suited for internal agent-to-database, orchestrator-to-worker, and microservice calls where both sides share one trust domain. They are not designed for an external user's coding agent walking up to a public SaaS front door: third-party providers do not run your internal SPIRE trust bundle, and a workload SVID attests a compute container rather than a human customer who delegated terms acceptance.

Short-lived Ed25519 brokered assertions (Agent Identity Protocol v2.3.0)

Short-lived brokered assertions handle the public third-party front door where no prior relationship exists between the user's agent and the provider. Under the Agent Identity Protocol (v2.3.0, wire version 2.0), a provider publishes a public discovery document at /.well-known/agent-signup.json advertising its signup endpoint, audience, allowed issuers, and terms URL.

When an agent needs to sign up, the broker fetches and SHA-256 hashes the provider's terms, records the acceptance, and mints a 5-minute Ed25519 signed assertion with purpose: "signup". The JWT carries iss, aud, exp, jti, human.verified (confirming a verified email address), and accepted_rp_tos_hash. For returning sessions on new devices or harnesses, the protocol also supports 120-second uncached login assertions (purpose: "login") sent to endpoints.agent_login, covered in detail in the login with agent guide.

Providers verify these assertions locally against the broker's public keys at /.well-known/jwks.json with zero broker calls in the request path, then issue their own post-signup API keys, OAuth tokens, or session credentials. You can inspect a live reference exchange on the demo broker network.

Agent authentication methods compared

The table below summarizes how the four mechanisms differ by lifecycle stage, human attribution, revocation behavior, and limits.

MechanismBest lifecycle stageHuman attributionRevocationKey limits
Static API keysOngoing runtime API calls after an account already existsNone on the wire; tied only to the account that created the keyRotate or delete key at the provider; breaks all callers sharing itNo per-agent isolation if shared; no terms trail; cannot bootstrap signup
OAuth 2.1 / OIDC (incl. MCP OAuth)Delegated access to existing accounts and MCP tool serversStrong via interactive user consent and scoped refresh tokensRevoke grant or refresh token at the authorization serverRequires pre-existing account or registration; does not hash-pin third-party terms
mTLS / SPIFFE workload SVIDsInternal service-to-service calls inside one trust domainNone; identifies attested compute workload, not an end userShort SVID TTLs plus trust bundle or workload entry removalDoes not cross unrelated public SaaS domains for customer signup
Ed25519 brokered assertionsPublic third-party agentic signup and cross-device re-loginVerified human email (human.verified), agent ID, and SHA-256 terms hashBroker kill switch stops new assertions and inbox access; provider keeps own account controlsOnboarding proof only (5m signup, 120s login); not a runtime bearer key

How the mechanisms fit together in practice

In a working architecture, these methods form a sequence rather than competing options. A developer running a coding tool sees all four roles stay cleanly separated:

  1. MCP OAuth connects the coding tool. The user connects their harness to https://agentregistrar.dev/mcp over OAuth 2.1 with PKCE, selects one agent sub-identity during consent, and receives a scoped MCP token.
  2. Brokered Ed25519 assertion creates the account. When the agent needs a third-party service, it follows the account creation flow, fetches discovery, and obtains a 5-minute purpose: "signup" assertion carrying the terms hash and verified human owner.
  3. Provider returns its own runtime credential. Following the assertion verification guide, the provider validates the JWT against JWKS, creates or resolves the account, and returns its own scoped API key, session token, or OAuth grant for ongoing calls.
  4. Optional endpoints.agent_login handles new devices. If the user switches machines or resets local state, the agent mints a fresh 120-second purpose: "login" assertion to obtain a new provider session without sharing passwords.
  5. Kill switch stops new broker assertions. Toggling an agent's kill switch in the broker portal immediately halts new signup assertions, login assertions, and inbox access for that agent.

For product-by-product selection across enterprise IAM, token vaults, and open protocols, see the AI agent identity providers comparison.

Security boundaries and verification checks

Short-lived tokens reduce replay windows, not verification requirements. Any provider accepting brokered assertions must enforce the checks documented in the protocol security specification:

  • Pin the signature algorithm to EdDSA. Reject alg: "none", HMAC algorithms, and any header parameters that pull untrusted keys such as jku or x5u. Only resolve keys from the configured issuer's allowlisted JWKS endpoint.
  • Enforce single-use replay protection on jti. Store seen jti values at least through exp so an intercepted 5-minute signup or 120-second login assertion cannot be replayed.
  • Check issuer, audience, human status, and terms hash. Confirm iss matches your allowlist, aud matches your canonical origin, human.verified is true, and accepted_rp_tos_hash matches your served terms bytes.
  • Keep runtime scopes and rate limits on your side. Short assertion lifetimes do not replace provider authorization scopes, spend caps, or abuse rate limits on the credentials you issue afterward.

As detailed in trust and limits, the broker never holds provider API keys, passwords, or session tokens, and it cannot revoke credentials inside your database after signup. Revoking an agent at the broker stops future assertions; revoking runtime access remains the provider's control. Check the protocol FAQ for common edge cases around key rotation and account resolution.

Related topics

<- Back to topicsBrowse quick answers in the docs FAQ ->