cli/cli

Running `gh auth login --git-protocol https --web` does not respect `no` when asked to authenticate

tjementum opened this issue · 1 comments

Describe the bug

When I execute gh auth login --git-protocol https --web in the terminal and respond to the prompt ? Authenticate Git with your GitHub credentials? (Y/n) with either Y or n, I still receive a one-time code and the instruction Press Enter to open github.com in your browser....

Below is a video demonstrating the issue.

CleanShot 2024-05-13 at 14 06 40

This is a long-standing issue. I would love if there were a way to not even show the prompt as I have this in my one script.

@tjementum : thanks for opening up this issue and sorry this has been a point of friction for you! 🙇 Let's dig into what's going on here and figure out what can be done.

_Also, thank you for the screen share ❤ _

Looking at an abbreviated version of gh auth login --help, the --web flag is telling gh that you are not using a PAT to authenticate but using the GitHub CLI OAuth app. The --git-protocol flag is telling gh what protocol to use when executing git commands.

USAGE
  gh auth login [flags]

FLAGS
  -p, --git-protocol string   The protocol to use for git operations on this host: {ssh|https}
  -h, --hostname string       The hostname of the GitHub instance to authenticate with
      --insecure-storage      Save authentication credentials in plain text instead of credential store
  -s, --scopes strings        Additional authentication scopes to request
      --skip-ssh-key          Skip generate/upload SSH key prompt
  -w, --web                   Open a browser to authenticate
      --with-token            Read token from standard input

The Authenticate Git with your GitHub credentials prompt is about whether git uses gh as a credential manager.

@tjementum : What should GitHub CLI be doing in this scenario if not opening the browser to authenticate?