Repository navigation
Add a non-interactive device code login - #7220
Draft
maksim-zuev-db wants to merge 3 commits into
Draft
maksim-zuev-db wants to merge 3 commits into
maksim-zuev-db wants to merge 3 commits into
Conversation
Contributor
|
Commit: Regression test reportSelected 5 changed tests (limit=20, 0 not selected) 5 tests: regression=5 unreleased=0 coverage=0 failing=0
TestAccept/cmd/auth/login/device-code/non-interactive/concurrent: branch ✅ | main (35ed095) ❌ | latest (v1.22.1) ❌main (35ed095): latest (v1.22.1): TestAccept/cmd/auth/login/device-code/non-interactive/errors: branch ✅ | main (35ed095) ❌ | latest (v1.22.1) ❌main (35ed095): latest (v1.22.1): TestAccept/cmd/auth/login/device-code/non-interactive/flags: branch ✅ | main (35ed095) ❌ | latest (v1.22.1) ❌main (35ed095): latest (v1.22.1): TestAccept/cmd/auth/login/device-code/non-interactive/nominal: branch ✅ | main (35ed095) ❌ | latest (v1.22.1) ❌main (35ed095): latest (v1.22.1): TestAccept/cmd/auth/login/device-code/unsupported-host: branch ✅ | main (35ed095) ❌ | latest (v1.22.1) ❌main (35ed095): latest (v1.22.1): |
Collaborator
Integration test reportCommit: adfe6a4
Top 6 slowest tests (at least 2 minutes):
|
maksim-zuev-db
force-pushed
the
device-code-agent-login
branch
from
October 28, 2026 14:05
4ff0b1e to
1b2be13
Compare
maksim-zuev-db
changed the base branch from
device-code-split-steps
to
device-code-interactive-tests
October 28, 2026 14:06
maksim-zuev-db
force-pushed
the
device-code-agent-login
branch
from
October 28, 2026 14:35
1b2be13 to
26349d5
Compare
maksim-zuev-db
force-pushed
the
device-code-agent-login
branch
from
October 28, 2026 14:45
26349d5 to
90d5979
Compare
IsPromptSupported tells whether the CLI can render a prompt, so it also depends on stderr, NO_COLOR, TERM=dumb and Git Bash. A command that reads a plain line from stdin only needs to know whether a user can type into it. Co-authored-by: Isaac <no-reply@databricks.com>
A non-interactive device code login is completed by a later CLI invocation. Entry gets a PendingLogin field that holds the device code and the user code until then, so that the device code stays in the user's token storage instead of being printed or passed on the command line. A pending entry has no token. Co-authored-by: Isaac <no-reply@databricks.com>
Device code login reads the confirmation code from stdin, which only works when someone can type into the command. An AI agent or a script that runs the login as a one-off command cannot. When stdin is not a terminal, auth login --use-device-code requests the device authorization, stores the device code as a pending login in the token store, and prints the URL and the user code. Running the same command with the hidden --user-code and --confirmation-code flags exchanges the pending device code and then saves the login like any other. The device code never leaves the machine, so a confirmation code that ends up somewhere else, such as an agent's transcript, cannot complete the login elsewhere. The pending login is keyed by the login's cache key with a #device-code suffix, so the current token keeps working until the login completes. A new login for the same target replaces it, and the user code tells a replaced login apart without sending its confirmation code to the server. Co-authored-by: Isaac <no-reply@databricks.com>
maksim-zuev-db
force-pushed
the
device-code-agent-login
branch
from
October 28, 2026 15:42
cf4b0e9 to
adfe6a4
Compare
maksim-zuev-db
changed the base branch from
device-code-interactive-tests
to
device-code-pending-login-storage
October 28, 2026 15:48
maksim-zuev-db
changed the base branch from
device-code-pending-login-storage
to
device-code-interactive-tests
October 28, 2026 15:57
maksim-zuev-db
requested review from
simonfaltum
and removed request for
simonfaltum
October 28, 2026 16:03
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #7222.
Changes
When stdin is not a terminal,
auth login --use-device-coderuns in two steps. The first step stores the device code as a pending login in the token store and prints the URL and the user code. Running the same command with the hidden--user-codeand--confirmation-codeflags exchanges the pending device code and then saves the login like any other. In a terminal, the login stays interactive.Each profile, or host without a profile, has one pending login, and a new login for it replaces the old one. The second step checks the user code, so completing a replaced login fails with a clear error without sending its confirmation code.
The pending login is a new
PendingLoginfield ofstorage.Entry, persisted by the file, keyring, and memory stores. The flow is picked with the newcmdio.IsInputTTY, which, unlikeIsPromptSupported, does not depend on stderr,NO_COLOR,TERM=dumb, or Git Bash.Piped stdin. Before this change, a confirmation code piped into stdin (
printf CODE | databricks auth login --use-device-code ...) completed the login. Now any stdin that is not a terminal starts the two-step login, and piped input is ignored. Nobody needs the old pattern in practice: the confirmation code only appears in the browser after the login is started and approved, so it can't be piped in up front. A script would have to keep stdin open and write the code later, and the second step with--confirmation-codecovers that case.Why
An AI agent or a script that runs the login as a one-off command cannot type the confirmation code into a running
auth login. The device code never leaves the machine, so a confirmation code that ends up in an agent's transcript cannot complete the login elsewhere.Tests
Unit tests cover storing a pending login in each store and
IsInputTTY. Acceptance tests underdevice-code/non-interactivecover both steps, flags, errors, and concurrent logins.termtesttests cover the second step run in a terminal, where it must not prompt. The interactive flow is covered by thetermtesttests from #7222.No changelog fragment:
--use-device-codeis still behindDATABRICKS_CLI_DEVICE_CODE.This pull request and its description were written by Isaac.