Library / Documentation
OAuth 2.0 Overview
The canonical guide to OAuth 2.0 grants, tokens and security considerations.
By OAuth Community · oauth.net · Added 2026-08-30
All content belongs to OAuth Community / oauth.net. We only link to it and give credit. Report a problem
Learn this doc
About 30 min left. Your work is saved as you go.
What you want from these docs
oauth.net documents a tool you may use. Decide what you want to do with it, then read only what answers that.
Ideas you will meet
- OAuth
- Delegated authorization flows for APIs and apps.
- API Gateway
- A single entry point for routing, auth and throttling.
What we already know about this
Our own lessons on these ideas. Read them here before you start, so it makes sense.
Core Concepts: How Things Actually Work · 9 minSSO, OAuth 2.0 and OpenID ConnectHow 'Sign in with Google' works, and the difference between authentication and authorisation.Read here
Two questions, two words
- Authentication: who are you?
- Authorisation: what are you allowed to do?
OAuth 2.0: delegated access
OAuth 2.0 lets a user give an app limited access to their data at another service, without sharing their password. Roles:
- Resource owner: the user.
- Client: the app asking for access.
- Authorization server: issues tokens (for example Google, GitHub).
- Resource server: the API holding the data.
The user grants specific scopes (for example "read my calendar"), and the client receives an access token that is limited to those scopes and expires.
The authorization code flow
100%Figure SDA-CORE-07-1 · Authorization code flow · © forcsguy.com
Important details:
- state: a random value you check on return, which stops attackers forging the callback (CSRF).
- PKCE: a one-time proof that the party exchanging the code is the one that started the flow. Use it for all clients, essential for mobile and single-page apps.
- Register exact redirect URIs and compare them strictly.
OpenID Connect: adding identity
OAuth alone says "this token may call the API", not "this is Jane". OpenID Connect (OIDC) adds an ID token (a signed JWT) with claims about the user: subject id, email, name. To sign someone in, validate the ID token's signature, issuer, audience and expiry.
SSO
With single sign-on, many applications trust one identity provider. The user signs in once; the provider vouches for them to each app. Enterprises use SAML or OIDC for this. Benefits: fewer passwords, central policies like MFA, and one place to revoke access when someone leaves.
Single sign-on means the second application never sees your password. It trusts the sign-in service you already used:
100%Figure SDA-CORE-07-2 · One sign-in, two applications · © forcsguy.com
Common mistakes
- Using the access token as proof of identity instead of validating an ID token.
- Skipping
stateor accepting any redirect URI. - Storing tokens somewhere scripts can read them.
- Requesting more scopes than the feature needs.
More on this site
Related reading
- RFC 6749: The OAuth 2.0 Authorization FrameworkIETFDocumentation
- OAuth 2.0 OverviewOAuth Community · oauth.netDocumentation
- Introduction to JSON Web TokensAuth0 · jwt.ioDocumentation
- System Design 101ByteByteGo · ByteByteGoHqGitHub
Show 6 moreShow fewer
- OAuth Audit Toolbox at IndeedIndeed engineers · IndeedCase Studies
- The Architecture of Open Source ApplicationsVarious authors · aosabook.orgBooks
- Secret Detector: Preventing Secrets in Source Code at YelpYelp engineers · YelpCase Studies
- LevelDBGoogle · GitHubGitHub
- Garbage Collection in Go Application at TwitchTwitch engineers · TwitchCase Studies
- DevOps resource center - Azure DevOpsMicrosoft engineers · MicrosoftBlogs
Advanced Distributed Systems · 12 minLoad balancing: layer 4, layer 7 and gatewaysWhat a load balancer can see and do at each layer, the algorithms behind it, and how API gateways add routing, aggregation and policy.Read here
What a load balancer sees
A load balancer spreads incoming work across servers, removes failed servers and makes scaling invisible to clients. What it can do depends on which layer it works at.
Layer 4 (transport) Layer 7 (application) Sees IP addresses, ports, TCP/UDP connections HTTP method, URL, headers, cookies, body Decides by Connection details Request content TLS Passes through, or terminates in some products Usually terminates TLS Speed and cost Very fast, low overhead More work per request Typical features Spread connections, health checks Path routing, header rules, sticky sessions, rewrites, caching, WAF rules Examples Network load balancers, LVS, HAProxy in TCP mode NGINX, Envoy, HAProxy HTTP mode, cloud application balancers 100%Figure SDA-ADS-05-1 · Layers of balancing in front of an app · © forcsguy.com
Many designs use both: an L4 tier for raw scale and an L7 tier for smart routing.
Before: layer 4: ports and addresses
100%After: layer 7: reads the request
100%What changed
- Layer 7 can route by path, header or cookie
- Layer 7 can terminate TLS and retry safely
- Layer 4 is simpler and faster, with less to configure
Choosing a target: algorithms
- Round robin / weighted round robin: simple rotation; weights favour bigger machines.
- Least connections (and weighted): send to the server with fewest active requests; good when requests vary in length.
- Least response time: combine active load with measured latency.
- IP hash / consistent hashing: the same client or key goes to the same server, useful for caches and sticky state (see consistent hashing).
- Resource-based: servers report load and the balancer follows.
Health checks (active probes and passive error tracking) remove unhealthy servers; connection draining lets in-flight requests finish before a server is removed during a deploy.
Global and DNS balancing
Across regions, DNS-based or global server load balancing directs users to the nearest or healthiest region (see the DNS and CDN lessons). DNS answers are cached, so failover takes as long as the TTL; anycast and global balancers react faster.
API gateway: policy at the edge
An API gateway is an L7 component specialised for APIs. Beyond routing it commonly provides:
- Authentication and authorisation (validate tokens, apply scopes),
- Rate limiting and quotas (see the rate-limiter lesson),
- Request and response transformation, versioning, and protocol translation,
- Aggregation: one client call fans out to several services and merges results, saving round trips for mobile clients,
- Caching, logging, metrics and tracing in one place.
100%Figure SDA-ADS-05-2 · Gateway routing and aggregation · © forcsguy.com
Risks: the gateway is a single entry point (run several instances, keep it stateless) and can become a bottleneck or a place where business logic piles up. Keep it to cross-cutting concerns. A variation is a backend for frontend: one gateway per client type (web, mobile) tailored to its needs.
Inside the cluster
Between services, balancing is done by client-side libraries or sidecar proxies that know the healthy instances from service discovery, so no central balancer is needed for east-west traffic. See the microservices lessons for service mesh ideas.
Failure habits
- Run at least two of every balancer and gateway instance across zones.
- Keep timeouts and retry budgets (see the resilience lesson) so the balancer does not amplify an outage.
- Use slow start for new instances so they warm up before taking a full share.
Real-world reading
Related reading
- Maglev: A Fast and Reliable Software Network Load Balancer (paper)Eisenbud et al. · GooglePapers
- NGINX HTTP Load BalancingNGINX · F5 / NGINXDocumentation
- Scaling Your API with Rate LimitersPaul Tarjan · StripeBlogs
- Active-Active for Multi-Regional ResiliencyNetflix Engineering · NetflixCase Studies
Show 6 moreShow fewer
- ByteByteGo: System Design Video SeriesAlex Xu · ByteByteGoYouTube
- Rate Limiting with NGINXNGINX · F5 / NGINXBlogs
- Implementing health checksAmazon Builders' Library · Amazon Web ServicesBlogs
- Google SRE Book: Load Balancing in the DatacenterGoogle SRE team · GoogleBlogs
- Traffic Steering using Rum DNS at LinkedInLinkedIn engineers · LinkedInCase Studies
- Google SRE BookBetsy Beyer et al. · GoogleCourses
Go deeper on this
A path through videos, articles, other case studies and code on the same ideas as OAuth 2.0 Overview.
Warm upGet the vocabulary first.
Courses
Hello Interview: System Design in a Hurry
Free written guide covering the delivery framework, core concepts and key technologies.
Hello InterviewIntermediate
Documentation
Microservices Patterns Catalog
Pattern language for microservices: saga, API gateway, CQRS, event sourcing and more.
microservices.ioIntermediate
WatchHow others solve the same problem, on video.
Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)
ReadEngineers explain it in their own words.
Blogs
Hasura Blog
The top stories from Hasura: engineering, tutorials, product updates, GraphQL, frontend backend frameworks more!
HasuraIntermediate
Blogs
Postman Blog
The Postman blog is your hub for API resources, news, and community. Learn about the Postman API Platform and much more.
PostmanIntermediate
See it in another companyThe same ideas, a different system.
Case Studies · Read here
OAuth Audit Toolbox at Indeed
Integrating third party apps with GSuite can be risky. Indeed's OAudit Toolbox allows you to educate your users and improve application security.
IndeedIntermediate
Case Studies · Read here
Stripe's payments APIs: the first 10 years
How a payments API evolved over a decade, with lessons on versioning and backward compatibility.
StripeIntermediate
Read the codeSee how it looks when it is real.
GitHub
System Design 101
Visual cheat sheets explaining complex systems in simple terms.
ByteByteGoHqBeginner
GitHub
Awesome Microservices
Curated tools, frameworks and reading material for building microservice systems.
mfornosIntermediate
Keep learning
Loading community…