Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is the Device Code Flow?

The device code flow lets a device with no browser or keyboard get an access token: it shows a short code, and the user approves it on a phone or laptop instead.

Illustration for the cybersecurity term Device Code Flow
Home / Blog / Cybersecurity Terms / What Is the Device Code Flow?
17 November 2026

What Is the Device Code Flow?

What Is the Device Code Flow?

You have used this flow even if you have never heard of it. A smart television displays an eight-character code and a short URL; you type both into your phone, sign in there, and a few seconds later the television is logged in. That is the OAuth 2.0 device authorisation grant, defined in RFC 8628, and it exists for one reason: entering a password with a remote control or on a device with no browser at all is intolerable.

The Sequence

  1. The device posts its client identifier to the authorisation server’s device authorisation endpoint.
  2. The server returns a device code (long, machine-readable, kept by the device), a user code (short, human-readable), a verification URL, an expiry, and a polling interval.
  3. The device displays the user code and URL on screen.
  4. The user opens the URL on a phone or laptop, authenticates there with whatever factors are required, and enters the code.
  5. Meanwhile the device polls the token endpoint with grant_type=urn:ietf:params:oauth:grant-type:device_code, receiving authorization_pending until the user finishes, then an access token and usually a refresh token.

Two properties fall out of that design, and both matter. The device never handles the user’s credentials. And the approval happens on a completely different device, over a channel the approving browser cannot inspect.

Device Code Phishing

That second property is the problem. Nothing in the flow proves that the person entering the code is sitting in front of the device that requested it.

The attack writes itself. The attacker starts a device code flow against the victim’s own tenant, receives a genuine user code, and sends it to the target with a plausible instruction—join the briefing, activate your new handset, verify your account for the migration. The victim goes to the real Microsoft or Google sign-in page, with the real certificate and the real domain, authenticates with their real second factor, and types the code. Tokens are issued to the attacker.

There is no fake website to spot, no lookalike domain, and no certificate warning. Conditional access is evaluated against the user’s own compliant device and passes. Microsoft Threat Intelligence documented a sustained campaign using exactly this technique in February 2025, attributed to the actor it tracks as Storm-2372, targeting government, defence, and NGO accounts through messaging platforms. The same pattern has appeared in reporting on several other state-linked groups since.

Defending Against It

Where It Sits Among the Grants

The device code flow is one of three grants still in regular use for interactive scenarios, and choosing correctly matters. For anything with a browser—web applications, mobile apps, single-page applications—use the authorisation code flow with PKCE. For server-to-server work with no user at all, use the client credentials flow. The device code grant is specifically for input-constrained devices, and using it anywhere else trades a real security property for convenience.

Where you do use it, the tokens it produces deserve the same treatment as any other. Keep refresh token lifetimes short, enable continuous access evaluation so revocation takes effect quickly, and make sure your revocation path is tested, because an incident response that depends on killing attacker sessions needs to work on the day.

At Privia Security, we include device code phishing and other consent-based techniques in our social engineering services.

FAQ – Frequently Asked Questions

Why Is Device Code Phishing So Hard to Spot?

Because every component the user sees is genuine. The sign-in page is the real identity provider on the real domain with a valid certificate, the multi-factor prompt is the user’s own, and conditional access evaluates their compliant device and passes. The only abnormal element is that the code arrived in a message rather than appearing on a screen in front of them.

Should I Disable the Device Code Flow Entirely?

Block it by default and allow it only for the specific applications and platforms that need it. Typical legitimate cases are shared meeting room displays, command line tooling, and some developer workflows. Audit sign-in logs first to see which applications currently use the grant, then build the allow list from evidence rather than from guesses about who might complain.

Does Multi-Factor Authentication Stop This Attack?

No. The victim completes multi-factor authentication correctly on their own device, and the tokens issued as a result go to the attacker. Only phishing-resistant authentication does not help here either, because the authentication itself is legitimate. The effective controls are blocking the flow, restricting where it is permitted, and user awareness of the single rule about codes received in messages.

How Do I Detect Device Code Abuse?

Alert on successful sign-ins using the device code grant, since the volume is normally very low. Then look at what follows: a token first used from an address, country, or user agent that does not match the user’s usual pattern, mailbox rule creation, or bulk file access shortly after a device code sign-in are all strong indicators worth escalating immediately.

Related Terms

You May Be Interested In These

How the Stuxnet Attack Worked

Cybersecurity Terms

17 November 2026

How the Stuxnet Attack Worked

Read More
What Are Scalping Bots?

Cybersecurity Terms

17 November 2026

What Are Scalping Bots?

Read More
What Is SAST?

Cybersecurity Terms

17 November 2026

What Is SAST?

Read More