IAM glossary
What is Device Code flow?
Device Authorization Grant
OAuth flow for devices with no browser or keyboard, like TVs and command line tools: the device shows a code, you sign in on your phone, the device polls until tokens arrive.
How it works
The Device Code flow is for devices with no browser or no comfortable keyboard: smart TVs, consoles, command-line tools. The device asks the authorization server for a device_code and a short user_code, and shows the user a URL and the code.
The user opens the URL on their phone or laptop, signs in there and types the code. Meanwhile the device polls the token endpoint every few seconds. As soon as the user approves, the device receives its tokens. The password is never typed on the TV.
A simple example
You open a streaming app on a new TV. It shows “Go to example.tv/activate and enter WDJB-MJHT”. You do it from your phone, already signed in, and confirm. A few seconds later the TV shows your profile.
Common mistakes
- Codes that last too long or polling with no limit: attackers can send someone a valid code and ask them to “activate” it (device code phishing).
- Not showing clearly on the approval page which device and which app are asking.
- Using it for apps that do have a browser, where Authorization Code with PKCE is safer.