Skip to content

gh auth login --with-token: provide clear, non-echoing token input when stdin is a terminal #14597

Closed as duplicate

Description

@vladkens

Describe the feature or problem you’d like to solve

I had an existing personal access token and wanted to authenticate from the terminal:

gh auth login --hostname github.com --git-protocol https --with-token

Two things made this confusing:

  1. There is no prompt or explanation of how to submit the token. The command displays nothing. I pasted my token and pressed Enter, but nothing happened. It took checking the source code to understand that the command waits for EOF, which requires Ctrl+D on macOS. There is no indication of this in the terminal, so it looks like the login has hung.
  2. The token is displayed in plain text. Pasting it leaves the full credential visible on screen and in terminal scrollback. I expected hidden input, like a password prompt.

The documentation shows file redirection, but running the command directly in a terminal provides no guidance about how to proceed.

Proposed solution

When stdin is a terminal, show an explicit prompt, hide the token by disabling terminal echo, and let Enter submit it.

GitHub CLI already has an AuthToken() prompter for hidden/masked input, which could be reused here. The intended behavior is like Go’s term.ReadPassword from golang.org/x/term or Python’s getpass.getpass: read the credential without displaying it. Keep existing behavior for pipes and file redirection.

If --with-token is intended exclusively for non-interactive input, immediately explain that and direct users to gh auth login → Paste an authentication token, instead of silently waiting.

Additional context

Reproduced with a dummy token on macOS 27.0.1 using gh 2.100.0.

Related: #9789, which covers the silent wait. This report also highlights the visible credential and the need for clear guidance during token entry.

Activity

  1. added
    needs-triage
    on Oct 5, 2026
  2. cli-triage commented on Oct 5, 2026

    @cli-triage

    Thanks for the detailed report. This looks like the same underlying root cause as #9789: when --with-token is set, gh auth login calls io.ReadAll(opts.IO.In) (login.go#L118-L124) unconditionally, with no check for whether stdin is a terminal and no prompt telling the user what to do. That explains the "hangs with no feedback" symptom from #9789, and also explains the plaintext-echo issue you describe here: since there's no special handling for an interactive TTY, the terminal's normal echo stays on while the process blocks waiting for EOF (Ctrl-D), which is also why Enter alone doesn't submit the input. I'm suggesting duplicate (of #9789, which already tracks the core hang/EOF behavior and is labeled for design) along with gh-auth for the relevant command area. Since this adds a distinct angle (masked/hidden input and an explicit terminal-only error path), a maintainer may still want to fold the specifics into #9789 or keep them linked — flagging both as suggestions for a human to confirm.

    Generated by Issue Triage (skills-driven) for #14597 · copilot · auto · 33.2 AIC · ⌖ 2.25 AIC · ⊞ 10.9K · ◷

  3. vladkens commented on Oct 5, 2026

    @vladkens
    Author

    I'm suggesting duplicate (of #9789 …)

    That issue has been open since October 2024, and the problem still exists. Token authentication is a basic CLI operation: users should not need to read the source code to discover how to submit a token, or have their credential displayed on screen.

    I’d submit a PR to fix this myself, but the repository’s contribution guidelines seem to prohibit external PRs for this issue. That’s why I’m bringing it up again: the problem still exists and needs to be fixed.

  4. babakks commented on Oct 5, 2026

    @babakks
    Member

    Thanks for raising this again, @vladkens! 🙏

    This is the same underlying interactive input problem already tracked in #9789, so I am going to close this as a duplicate.

    Your point about the token remaining visible in the terminal and its scrollback is useful additional context. The direction suggested by @williammartin in #9789, rejecting interactive terminal input with a clear explanation, would technically change the behavior for anyone currently pasting a token and submitting it with Ctrl+D. However, I think that is acceptable because this option is intended to read the token noninteractively from standard input.

    Thanks again for highlighting that the current behavior is both confusing and capable of exposing the credential.

  5. added
    duplicate
    gh-auth
    on Oct 5, 2026
  6. removed
    needs-triage
    on Oct 5, 2026
  7. removed
    duplicate
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gh-auth

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions