Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tjementum opened this issue May 13, 2024 · 2 comments
Labels
bug Something isn't working gh-auth relating to the gh auth command

Comments

@tjementum
Copy link

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 tjementum added the bug Something isn't working label May 13, 2024
@cliAutomation cliAutomation added the needs-triage needs to be reviewed label May 13, 2024
@andyfeller
Copy link
Contributor

@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?

@andyfeller andyfeller added gh-auth relating to the gh auth command and removed needs-triage needs to be reviewed labels May 16, 2024
@tjementum
Copy link
Author

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

If I get a question: Authenticate Git with your GitHub credentials? and I answer No I expect that it does not try to authenticate me ;)

My bug report here is that the tool behaves exactly the same whether I answer Yes or No, so my question is, why is it not To continue press any key or just skip the question altogether?

In my case, I want to answer No because I’m running the same command over and over, so I have already trusted my terminal to communicate with GitHub.

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

I don't even know what the difference is 😊 The tool behaves exactly the same to me. Maybe the solution is then to make a prompt that better explains what I'm answering.

Also, I explicitly added the --web so I clearly do not want to use a Personal Access Token. But maybe I'm mixing things up here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gh-auth relating to the gh auth command
Projects
None yet
Development

No branches or pull requests

4 participants
@tjementum @andyfeller @cliAutomation and others