Skip to main content
This section uses an example from Alan’s warehouse database server to explain common OAuth pitfalls and correct authorization behavior. Consider the token presented with a request. Each token contains several claims you can inspect; one important claim is the audience (aud) — the intended recipient of the token. Example token:
In this scenario the token with "aud": "billing" was presented to the warehouse server. The warehouse server accepted and executed the request without complaint — but it was never authorized to do so. This is a classic case of token misuse.
Authorization behavior is specified per transport: the spec describes recommended practices but does not force every server to perform authorization in all transports. For remote transports (HTTP) the recommendation is to use OAuth 2.1. For local transports (stdio), credentials often come from environment variables and do not cross a network boundary.
A slide titled "Per Transport" comparing two setups: on the left an HTTP — Remote diagram shows a laptop client connecting over the network to a remote server, and on the right a stdio — Local diagram shows a client and server inside a local boundary exchanging messages (one labeled "password").

OAuth actors and their roles

When a client uses HTTP and OAuth, three parties typically participate: Summary: clients obtain tokens, the authorization server issues them, and the resource server validates them.

How a client discovers the right authorization server

Discovery generally happens in a few steps. The resource server helps the client find the authorization server by returning metadata hints. Below is a concise step-by-step flow.

Step 1 — Initial request triggers discovery hint

  • Client requests a protected resource without a token.
  • Resource server responds with 401 Unauthorized and a WWW-Authenticate header that points to resource metadata.
Example response header:
This header tells the client where to find guidance on how to obtain a valid token.

Step 2 — Resource metadata

  • The URL from the header hosts a published resource-server metadata document.
  • That document lists authorization servers the resource trusts and other metadata in a standardized format.

Step 3 — Authorization server discovery

  • The client selects an authorization server from the resource metadata list and fetches that server’s description.
  • The authorization server metadata includes the endpoints the client needs, for example:

Step 4 — Standard OAuth login (authorization code + PKCE)

  • The client directs the user to the authorization endpoint.
  • The user authenticates; the client receives a short-lived authorization code.
  • The client exchanges the code at the token endpoint for an access token. The code exchange should use PKCE (Proof Key for Code Exchange) to prevent authorization code replay attacks. See RFC 7636 for details.
A diagram titled "Step 4 – Standard OAuth Login" showing an OAuth Client (laptop) on the left, an Authorization Server (server rack) in the center, and a user icon labeled "Alan" on the right. An envelope marked "token" points from the client to the server, and an arrow shows the server communicating back to the user.

Audience (aud) claim and the resource parameter

When requesting a token, the client indicates the intended target with parameters such as resource (RFC 8707) or other audience mechanisms. The authorization server encodes this intent into the token’s aud claim. A resource server must perform a simple check on every incoming token: verify the aud matches the server identifier (i.e., “is this token meant for me?”). If the audience does not match, the resource must reject the request. In Alan’s case, the warehouse server skipped the audience check and accepted a token issued for "billing". Accepting such a token is called token passthrough and is explicitly forbidden by the specification.
A dark presentation slide titled "Forbidden Outright" with a boxed specification excerpt about "Token Passthrough." The text states token passthrough is explicitly forbidden and MCP servers "MUST NOT" accept tokens not issued for them.
A resource server MUST validate the token signature, expiration, and the audience (aud) claim and reject any token not issued for that server. Token passthrough is explicitly forbidden.

Token delegation and calling upstream services

The same audience principle applies when a server calls an upstream service on behalf of a request:
  • Do not forward an inbound token to an upstream service unless that token’s audience explicitly includes the upstream service and your security model allows delegation.
  • Obtain a token whose aud identifies the upstream service via an appropriate OAuth flow (client credentials, on-behalf-of, or other delegation mechanism).
Best-practice checklist:
  • Validate inbound tokens fully: signature, exp, aud, iss, and scopes/permissions.
  • When making outbound calls, present a token intended for the upstream service.
  • Use standard OAuth grants for machine-to-machine tokens and delegation (client credentials, on-behalf-of).
  • Avoid reusing or forwarding tokens issued for other audiences.

Key takeaways

  • Authorization behavior is transport-aware; follow the recommended practices for your transport (e.g., OAuth 2.1 for HTTP).
  • Use discovery metadata so clients can find authorization servers securely.
  • Always validate tokens, and always enforce the aud claim.
  • Never accept or forward tokens that were not issued for the service handling the request.

Watch Video