Lion Cipher Lab

Log in a device with the OAuth 2.0 device flow

Why it matters

Every time you log a smart TV, a games console, a CLI tool (the GitHub CLI, the AWS CLI, kubectl plugins), or a headless IoT gadget into an account, you are using the OAuth 2.0 Device Authorization Grant — RFC 8628, the 'device flow'. It exists because those devices have no browser, no keyboard, or both: you can't run the normal 'redirect to a login page' dance on a device where typing a password is miserable or impossible. The device flow's trick is to move the login to a device you DO have a good browser on — your phone or laptop — while the constrained device just waits. In this lab you…

What you'll learn

Steps in this lab

  1. When you'd reach for the device flow — and when you must not
  2. Start a real authorization server: Keycloak in Docker
  3. Create a realm, a user, and a public client with Device Grant enabled
  4. Act as the device: call the device authorization endpoint
  5. Act as the human: approve at the verification URI on a second screen
  6. Act as the device again: poll the /token endpoint
  7. Decode the tokens to prove who logged in
  8. The sharp edges: user_code entropy, phishing, and why not a browser app

Open the full interactive lab →