Protocol practice · Federation & Identity Standards

OAuth 2.0: the authorization code flow, with PKCE

Objective: You’re building Lumen Notes, which shows a user’s calendar events. Get permission to read their calendar and fetch today’s events, without ever seeing their password.

About 10 minutes · simulated, no real servers
  1. 1Ask for access
  2. 2Handle the callback
  3. 3Swap the code
  4. 4Keep the tokens
  5. 5Call the API
Where OAuth fits
AccessWhat may this app do?
OAuthYou are here
AccountsDoes the account exist?
Not sure? Which protocol?

OAuth at work, every day

Each of these asks you to approve a limited token, never your password.

  • A scheduling app reads your calendarRead access to events, nothing else.
  • A chat integration posts to a channelWrite access to one place, revocable any time.
  • A backup tool copies your filesLong-running access, renewed with a refresh token.

Step 1 of 5

Send the user to sign in

Your app builds a link to the authorization server and sends the browser there. Four values in it are yours to choose.

GET https://auth.example/authorize
?response_type=______
&client_id=lumen-notes
&redirect_uri=https://notes.example/callback
&scope=______
&state=______
&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
&code_challenge_method=______

Fill in the four blanks, then send the request.

response_type: what you want back
scope: what the feature needs
state: how you’ll know the answer is yours
code_challenge_method: how the challenge was made
Pick an answer for each blank to continue.