Sitemap
Production Ready

Production Ready: backend engineering that survives production — Spring Boot, data, distributed systems, JVM tuning, and AI in prod, with runnable code and honest tradeoffs.

OAuth2 Explained Like You’re Building It (Not Just Using It)

8 min readOct 20, 2026

--

Stop memorising abstract flow diagrams. This post walks through building OAuth2 from the wire up — actual HTTP requests, token anatomy, PKCE, refresh tokens, and JWT validation in Spring Boot.

Why Most OAuth2 Explanations Fail

Press enter or click to view image in full size

You can draw the OAuth2 flow diagram from memory and still have no idea why you’re getting a 401 in production. That gap — between recognising the boxes and arrows and actually understanding what’s on the wire — is where every backend developer gets stuck. Every tutorial starts with the same abstract picture: “Resource Owner,” “Authorisation Server,” “Client.” You nod along, then freeze the moment a token gets rejected for a reason the diagram never mentioned.

After 17 years of building authentication systems across banking, fintech, and e-commerce in Singapore, I’ve learned that the only way to truly understand OAuth2 is to see what’s happening on the wire. What bytes are actually being exchanged. What each token contains. Why things break.

Let’s build it from scratch.

The Core Problem OAuth2 Solves

--

--

Anupam Sinha
Anupam Sinha

Written by Anupam Sinha

Java · Spring Boot · Microservices · AI. Technical Architect with 17 years of enterprise experience. Writing what I wish I had when I started.

Production Ready
Production Ready

Published in Production Ready

Production Ready: backend engineering that survives production — Spring Boot, data, distributed systems, JVM tuning, and AI in prod, with runnable code and honest tradeoffs.