OAuth 2.0 is easy to use and hard to picture. A login button triggers redirects between three or four parties, each carrying parameters with similar names, and most bugs come from one party skipping a check it was supposed to make. A sequence diagram is the clearest way to see who sends what to whom, and in which order.
This post draws the flow you should use today for almost every client: the authorization code grant with PKCE. It walks through each step, explains what each party checks, and lists the older flows that current guidance tells you to drop.
The four parties
Role in the spec In practice Holds
Resource owner The user Their credentials
Client Your web app, single-page app or mobile app The tokens it receives
Authorization server Your identity provider User accounts, consent, signing keys
Resource server Your API The data, and the rules for which tokens it accepts
The client never sees the user's password.…