Joel Stevick

Episode 2 of 3 · 7:01

OAuth Deep Dive with an MCP Server (OAuth 2.1, PKCE)

What this episode covers

The OAuth machinery, step by step, in the flow Claude Code follows when it connects to an MCP server: the 401 and its WWW-Authenticate header; the protected resource metadata document and the authorization server's metadata document; the authorize request with its client ID metadata document and PKCE code challenge; consent; how the authorization code gets from the browser into Claude Code (a local HTTP server on 127.0.0.1, the loopback redirect URI, localhost resolution, the loopback interface and the state check); the exchange at the token endpoint; OAuth's front and back channels; the access token on every request; and a 403 that asks for more scope.

At the end: every request of the OAuth flow in order, and its first step to run yourself with curl against a real MCP server.