iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
OAuth device flow lets a command-line tool or AI agent obtain delegated access without embedding a full web browser. The client requests a short user code and a verification address, displays them, and waits while you approve the request on a phone or computer. After approval, it polls the authorization server and receives an access token, and sometimes a refresh token.
The flow is formally called the OAuth 2.0 Device Authorization Grant and is standardized in RFC 8628. It is intended for internet-connected clients with no suitable browser or with impractical text entry—such as CLIs, headless servers, TVs and some agent runtimes—not as a replacement for browser-based OAuth in capable smartphone apps.
What is OAuth device flow?
OAuth device flow separates the software requesting access from the device where a person signs in. A CLI or agent can make HTTPS requests but may not be able to open a browser, receive a redirect, or provide a comfortable text-entry interface. It therefore starts a device-authorization session and asks the user to finish it elsewhere.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallThe authorization server returns five important values: a high-entropy device_code, a short user_code, a verification_uri, a required expires_in lifetime, and, optionally, an interval for polling. Some servers also return a complete verification URI that can be encoded as a QR code. The human types or scans the user-facing code; the client keeps the device code private and uses it only in its token request.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
After the user visits the verification address, signs in and consents to the requested scopes, the client polls the token endpoint. The server eventually returns tokens, an authorization error, or an expiration response. Until then, the client must wait according to the server’s polling rules.
When should a CLI or agent use device authorization?
Use it when the client is connected to the internet but cannot reasonably perform a normal browser redirect. Typical cases include:
- A shell program running on a remote or headless host.
- A terminal application that cannot listen for an incoming redirect.
- A television or other constrained device with difficult text input.
- An AI agent that needs a human to approve access while the agent remains in a terminal, sandbox or hosted runtime.
The protocol requires outbound HTTPS, a way to display a URL and code, and a second device for the user’s interaction. RFC 8628 explicitly says it is not intended to replace browser-based OAuth in capable native applications. A mobile app that can open a system browser and receive a redirect should normally follow the native-app authorization practices instead.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
How does the OAuth device-code sequence work?
The interaction is a short, user-triggered session. Each stage has a separate security or reliability purpose.
1. Start only after the user asks
When the user chooses “Log in,” “Connect account” or an equivalent command, the client sends its client identifier and requested scope to the provider’s device-authorization endpoint over HTTPS. It should not silently create a session at application startup, nor start a new session after every failed attempt. Requiring an explicit action prevents an agent or a broken retry loop from generating repeated approval prompts.
2. Receive the session values
The authorization server responds with the device code, user code, verification URI, expiration lifetime and optional polling interval. The device code is protocol credential material with enough entropy that guessing it should be impractical. The user code is deliberately shorter and easier to type. A complete URI may be supplied for QR or other non-text presentation.
3. Display a clear prompt
Print the verification URI and user code in a form that can be selected or read from a screen. State which account or service is being connected, what scopes are requested, how long the request remains valid, and that approval must happen on another device. Show the user code, never the device code.
Recommended Free Tools
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
A good prompt provides both a text path and a QR or complete-URI shortcut when available. The text URL and code remain important for accessibility, for users who do not want to scan a QR image, and for checking that the displayed request is the one they intended to approve.
4. Approve on the second device
The user opens the verification URI on a phone or computer, authenticates with the service, verifies the displayed code or device details, and accepts or declines the requested access. The authorization page should make it possible to confirm that the code and device match; this reduces the chance of approving a phishing or impersonated request.
5. Poll the token endpoint correctly
After displaying the prompt, the client posts the device code and the required grant type, urn:ietf:params:oauth:grant-type:device_code, to the token endpoint. It waits at least the returned interval between requests. If the server does not provide an interval, RFC 8628 requires a five-second wait. Polling faster than allowed can trigger throttling.
A slow_down response means the client must increase its interval by five seconds for subsequent requests. The client should use a timer rather than a tight loop and should stop polling as soon as the session succeeds, is denied or expires.
6. End with a deterministic result
A successful response contains an access token and may contain a refresh token. The client stores them securely and continues the requested operation. authorization_pending is not a failure: it means the user has not finished and polling may continue. access_denied is final for that session and should return control to the user without more polling. expired_token means the authorization window ended; the user must initiate a fresh request.
What should the terminal show the user?
The terminal message is part of the security boundary, not just a user-interface detail. It should identify the service, the account context when known, the scopes, the verification address, the human-entered code and the expiration time. It should offer an explicit cancel action and explain that approval occurs on a second device.
A concise prompt can look like this in substance:
- “Connect this terminal to your account.”
- “Requested access: list files and create deployments.”
- “On another device, open the verification address and enter the user code.”
- “Approve only if the code and device shown by the service match this request.”
- “Waiting for approval; press the cancel key to stop.”
Do not print access tokens, refresh tokens or the device code. Bearer tokens can authorize requests to anyone who obtains them, and terminal logs are commonly copied into tickets, CI artifacts and shell histories.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
How should polling and errors be implemented?
Polling is a state machine, not a generic retry policy. Keep the authorization session’s deadline, current interval and terminal status in explicit state.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minute| Server result | Client action |
|---|---|
| Success with access token | Stop polling, securely store the returned credentials and continue the operation. |
authorization_pending |
Wait at least the current interval, then poll again while the session is unexpired. |
slow_down |
Increase the interval by five seconds for later requests, then continue if the deadline has not passed. |
access_denied |
Stop immediately and tell the user that approval was declined. |
expired_token |
Stop and ask the user to start a new, explicit authorization request. |
Honor the server’s expiration value even if the local process is still running. A network timeout is different from a protocol decision: a temporary transport failure can be retried within the remaining lifetime, while an authorization error should not be hidden by retries. Keep error messages specific enough to guide the user without exposing token material.
How can an AI agent request access safely?
An agent should treat device authorization as a human approval checkpoint, not as a way to obtain standing permission invisibly. The agent can prepare the request and display the URL and code, but the user must deliberately trigger the request and approve the scopes on the second device.
Make the approval boundary visible
Before starting, show the exact operations the agent will perform and the scopes needed for them. Explain whether the permission is read-only, can change data, or can create external side effects. Include a cancel path that terminates the local polling loop and discards the session values.
Prevent repeated or parallel sessions
Do not start device authorization every time an agent process launches, every time a tool call fails, or every time a previous session expires. Gate the operation behind a user action and keep one active session per account or environment unless the provider explicitly supports more. This avoids a stream of confusing prompts and limits opportunities for a user to approve the wrong one.
Bind the prompt to the intended device
Tell the user which terminal, host or agent session is being authorized. Ask them to compare the code and device description shown by the authorization service with the prompt in front of them. A QR shortcut is useful, but it should complement—not replace—the visible text URL and code.
Protect the resulting credentials
Store access and refresh tokens in the host operating system’s secure credential facility when one is available. Restrict file permissions in environments without such a facility, redact credentials from exception messages, and prevent them from entering shell history, telemetry, screenshots or build logs. The agent should request the narrowest useful scopes and refresh credentials only according to the provider’s documented rules.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
What is the difference between device flow and browser authorization-code flow?
Both flows let a user delegate access without giving a client the account password, but they assume different client capabilities.
| Consideration | Device authorization grant | Browser authorization-code flow |
|---|---|---|
| Browser availability | Designed for clients without a suitable browser. | Assumes the client can open or hand off to a browser. |
| Redirect reception | No incoming redirect is required; the client polls. | The client receives an authorization response through a redirect mechanism. |
| Text entry | Uses a short user code, often alongside a QR or complete URI. | Usually relies on browser interaction and may avoid manual code entry. |
| Approval display | Approval happens on a second device, with a code or device confirmation. | Approval normally happens in the browser handoff associated with the app. |
| Completion behavior | Polling continues until approval, denial or expiration, subject to an interval. | The redirect returns the authorization result to the waiting client. |
| Best fit | CLIs, headless hosts, TVs and constrained input environments. | Capable native apps and other clients that can use a browser securely. |
Choosing device flow merely because it is convenient can produce a worse experience on a capable device. Use the grant that matches the client’s interface and redirect capabilities, and follow the provider’s current guidance for native applications.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →How does Microsoft Entra’s device-code example work?
Microsoft Entra documents a /devicecode endpoint for this pattern. Its documented flow gives the user 15 minutes by default from the device-code request to sign in, after which the client can obtain access and refresh tokens if authorization succeeded.
The 15-minute value is a Microsoft Entra default, not a universal OAuth limit. A client must use the expires_in value returned by the particular authorization server rather than hard-coding Microsoft’s lifetime for every provider. Microsoft also recommends supported authentication libraries such as MSAL when they fit the application, instead of hand-coding the protocol.
Why is a device-code login stuck polling?
Most “stuck” sessions are either waiting for a user action, polling too aggressively, or operating with a session that has already expired.
The user has not completed the approval
Check that the verification address was opened on a second device, the user code was entered correctly, the correct account was selected and the consent page was accepted. Until then, authorization_pending is the expected response.
The client is polling too quickly
Use the returned interval, or five seconds when no interval is supplied. After slow_down, add five seconds to the interval for every later request. A loop that ignores these rules can be throttled and make completion less likely.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
The code or session has expired
Stop the old loop and have the user start a new request. Do not automatically create another device session when the old one expires; that behavior can produce unattended approval prompts.
The wrong value was submitted
Verify that the token request contains the device code, not the short user code, and that the grant type is exactly urn:ietf:params:oauth:grant-type:device_code. The user code is for the human-facing verification page; the device code is for the token endpoint and should remain confidential.
The network path is unavailable
The client needs outbound HTTPS both to request the device code and to poll for tokens. Check proxy, firewall, DNS and certificate configuration, then retry within the existing expiration window. A transport error should not be reported as user denial.
Free tools Windows power users keep installed
One-click scans. No signup required.
What security checks should an implementation pass?
- User initiation: Begin only after a clear user action, not automatically at startup or after every failure.
- TLS: Use HTTPS for device-authorization and token requests, and validate certificates normally.
- Code separation: Display the user code; keep the high-entropy device code out of the terminal and logs.
- Scope transparency: Show requested permissions before approval and explain consequential actions.
- Device verification: Ask the user to confirm that the code and device shown by the service match the intended terminal or agent.
- Rate compliance: Respect the polling interval and apply the five-second increase required by
slow_down. - Credential hygiene: Store returned tokens in secure operating-system facilities where possible and redact them from diagnostics.
- Deterministic cleanup: Cancel timers, erase transient device-session values and stop polling on approval, denial, expiry or user cancellation.
These controls address the main risks of a remote approval flow: approving an impersonated device, leaking bearer credentials, creating unattended authorization requests and overwhelming the token endpoint.
What should an implementation checklist include?
- Register the client with the provider and identify the device-authorization and token endpoints from that provider’s documentation.
- Request only the scopes needed for the immediate operation.
- Start the request from an explicit login or connect action.
- Display the verification URI, user code, requested scopes, expiration and cancel instructions.
- Offer a complete-URI or QR shortcut when the provider returns one, while retaining the text path.
- Poll with the device-code grant type at the required interval.
- Handle success,
authorization_pending,slow_down,access_deniedandexpired_tokenseparately. - Persist tokens securely, never print them, and record only non-sensitive diagnostic data.
- Test cancellation, expiry, denial, throttling, network interruption and an already-approved request.
Following those steps gives a CLI or agent a predictable login experience while preserving the human decision that OAuth is designed to require.
Frequently Asked Questions
Can OAuth device flow work with no internet connection?
No. The client must reach the authorization and token endpoints over outbound HTTPS, and the user needs a connected second device to authenticate and approve the request. An offline terminal can display instructions, but it cannot complete the grant until connectivity is restored.
Is the user code safe to paste into a public issue or chat?
Treat it as short-lived session information and share it only with the person completing the authorization. It is not the same secret as the high-entropy device code, but someone who sees an active code may be able to interfere with the approval experience or trick a user into authorizing the wrong session.
Can a service approve a device-code request automatically?
The protocol is designed around a user authenticating and consenting at the verification address. Automation that bypasses that human decision changes the security model and should be implemented only through a provider-specific, separately documented service-to-service mechanism.
What happens to an unused device code after the user cancels?
The client should stop polling immediately and discard the transient session values. Whether the authorization server marks the code as revoked immediately is provider-specific, so a new attempt should use a newly issued device authorization request.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

