From fa65e9a3a04b741164a66a5ce5a25b8ef64f184e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 19 Oct 2026 18:13:04 +0200 Subject: [PATCH] internal/oauth: cleanup output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove extra newline before message - Include the token in the URL (instead of requiring the user to manually enter it on the website). - Improve the "call to action"; ENTER can be used to automatically open the browser (but the user can manually open it instead), and CTRL-C can be used to cancel the login. - Remove the "Waiting for authentication in the browser…" message, which could be confusing if no browser was opened (yet), instead print a message after successfully requesting the browser to be opened. When running `docker login`; docker login i Info → Using web-based login. To sign in with credentials on the command line, use 'docker login -u ' Your one-time device confirmation code is: NRJL-BLRL Open this URL to authenticate: https://login.docker.com/activate?user_code=NRJL-BLRL Press ENTER to open the URL in your browser, or Ctrl+C to cancel. After pressing `ENTER`, it either prints the "success" message; Press ENTER to open the URL in your browser, or Ctrl+C to cancel. Opening browser… or a failure when unable to launch a browser; Press ENTER to open the URL in your browser, or Ctrl+C to cancel. No browser found. Open the URL above manually to continue. Signed-off-by: Sebastiaan van Stijn --- docs/reference/commandline/login.md | 4 ++-- internal/oauth/manager/manager.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/reference/commandline/login.md b/docs/reference/commandline/login.md index b5e03c487d..458edd7b91 100644 --- a/docs/reference/commandline/login.md +++ b/docs/reference/commandline/login.md @@ -183,9 +183,9 @@ $ docker login Using web-based login. To sign in with credentials on the command line, use 'docker login -u ' Your one-time device confirmation code is: LNFR-PGCJ -Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate +Open this URL to authenticate: https://login.docker.com/activate?user_code=LNFR-PGCJ -Waiting for authentication in the browser… +Press ENTER to open the URL in your browser, or Ctrl+C to cancel. ``` After entering the code in your browser, you are authenticated to Docker Hub diff --git a/internal/oauth/manager/manager.go b/internal/oauth/manager/manager.go index 37bce932fa..77d17d0418 100644 --- a/internal/oauth/manager/manager.go +++ b/internal/oauth/manager/manager.go @@ -106,8 +106,9 @@ func (m *OAuthManager) LoginDevice(ctx context.Context, w io.Writer) (*types.Aut out = tui.NewOutput(streams.NewOut(w)) } out.PrintNote("Using web-based login. To sign in with credentials on the command line, use 'docker login -u '\n") - _, _ = fmt.Fprintf(w, "\nYour one-time device confirmation code is: "+aec.Bold.Apply("%s\n"), state.UserCode) - _, _ = fmt.Fprintf(w, aec.Bold.Apply("Press ENTER")+" to open your browser or submit your device code here: "+aec.Underline.Apply("%s\n"), strings.Split(state.VerificationURI, "?")[0]) + _, _ = fmt.Fprintln(w, "Your one-time device confirmation code is:", aec.Bold.Apply(state.UserCode)) + _, _ = fmt.Fprintln(w, "Open this URL to authenticate:", aec.Underline.Apply(state.VerificationURI)) + _, _ = fmt.Fprintln(w, "\n"+aec.Bold.Apply("Press ENTER")+" to open the URL in your browser, or "+aec.Bold.Apply("Ctrl+C")+" to cancel.") tokenResChan := make(chan api.TokenResponse) waitForTokenErrChan := make(chan error) @@ -138,9 +139,9 @@ func (m *OAuthManager) LoginDevice(ctx context.Context, w io.Writer) (*types.Aut } return } + _, _ = fmt.Fprintln(w, "\nOpening browser…") }() - _, _ = fmt.Fprint(w, "\nWaiting for authentication in the browser…\n") var tokenRes api.TokenResponse select { case <-ctx.Done():