JetpackDuba / Gitnuro

A FOSS Git multiplatform client for newbies and pros
https://gitnuro.com/
GNU General Public License v3.0
872 stars 44 forks source link

Stuck in authentication loop when attempting push to Github #162

Closed julius-boettger closed 9 months ago

julius-boettger commented 9 months ago

I switched to Gitnuro a few days ago (coming from Gitkraken) in an effort to move away from proprietary software. I really like it so far, even wrote my own custom theme already. But the following bug is pretty annoying.

Describe the bug

I am trying to push to a public Github repository I created from a system running NixOS. When clicking "Push" in Gitnuro I get prompted with "Introduce your remote server credentials" (see Screenshots). After entering either my Github account name and password or my Github account email and password and clicking "Continue", the prompt instantly closes and then opens again, giving me no further information to what just happened. I usually give up after this happens ~3 times. I suspect it will go on like this infinitely.

A git push from the command line works flawlessly, so I seem to be authenticated on my system in general. I usually authenticate using gh auth login.

git config --list shows no configured credential helper.

user.name=julius-boettger
user.email=[censored]
init.defaultbranch=main

I tried this out on a different machine running Windows and got it working after setting helper = C:/Program Files/Git/mingw64/bin/git-credential-manager-core.exe in .gitconfig.

I also tried setting up git-credential-manager similarly on my NixOS system. I verified that it was working by running git push from a terminal, which successfully started git-credential-manager and let me log in with Github.

git config --list then showed:

credential.credentialstore=secretservice
credential.helper=/nix/store/zq5flx8cbwmpr7b6bj8yw2q5mfz89ajc-git-credential-manager-2.3.2/bin/git-credential-manager
user.name=julius-boettger
user.email=[censored]
init.defaultbranch=main

Sadly, this didn't change the Gitnuro behavior that I described earlier. It was the exact same when having no credential helper set and using git-crendential-manager.

To Reproduce

Steps to reproduce the behavior:

  1. Clone a public Github repo you own
  2. Authenticate with gh auth login
  3. Verify that you are authenticated and git push from the terminal works
  4. Open the repo in Gitnuro and click on "Push"

Expected behavior

I expected to either be able to authenticate successfully or get some kind of error message popup. Instead I am stuck in an infinite authentication prompt loop.

Workaround

Use git push from the terminal instead of clicking "Push" in Gitnuro. Works, but is pretty annoying.

Screenshots

password_prompt

Desktop:

JetpackDuba commented 9 months ago

Hey! Thank you for your detailed report :smiley:

As far as I can see, the GitHub cli tool can be also used as an authenticator, but it's not supported right now (you can open a new issue about it and I'll try to add support for it).

However, I'm not really sure of why can't you authenticate with your credentials. Are you using a github token? Your user's password is no longer supported when trying to run git commands.

However you are right about the UI, the dialog should display an error.

julius-boettger commented 9 months ago

Thank you for your fast reply!

I checked my Github personal access tokens and there was indeed an expired one there that I forgot about.

After deleting it, I attempted authentication in Gitnuro again, trying both my Github account name and password and my Github account email and password, with no success. I was stuck in the same authentication loop as described in the original bug report.

I then created a new Github personal access token and attempted authentication in Gitnuro using it instead of my Github account password. And it worked! I was allowed to push.

But: I get the authentication prompt every single time I click on "Push". So my credentials don't appear to be saved...?

JetpackDuba commented 9 months ago

Thank you for your fast reply!

I checked my Github personal access tokens and there was indeed an expired one there that I forgot about.

After deleting it, I attempted authentication in Gitnuro again, trying both my Github account name and password and my Github account email and password, with no success. I was stuck in the same authentication loop as described in the original bug report.

Yes, that's because the GitHub policy changes. If you try it using CLI without setting up the GitHub CLI tool, the same thing will happen.

I then created a new Github personal access token and attempted authentication in Gitnuro using it instead of my Github account password. And it worked! I was allowed to push.

But: I get the authentication prompt every single time I click on "Push". So my credentials don't appear to be saved...?

It's something I've fixed for 1.3. Gitnuro will ask it just once every time it's opened (it's kept in memory). If you want to never write your credentials then Git Credentials Manager should fix that, but I'm not sure why didn't work for you. Can you share your .gitconfig file?

julius-boettger commented 9 months ago

It works now! Thank you for your fast support @JetpackDuba.

It was a NixOS-specific issue with setting git's credential helper through the home-manager option programs.git.extraConfig. This apparently writes the given config to ~/.config/git/config and not ~/.gitconfig, which either doesn't do anything at all or Gitnuro does not check for it there (I'm not sure).

For my fellow NixOS users stumbling upon this: Make sure this is in ~/.gitconfig (path to git-credential-manager may vary):

[credential]
    credentialStore = secretservice
    helper = /nix/store/zq5flx8cbwmpr7b6bj8yw2q5mfz89ajc-git-credential-manager-2.3.2/bin/git-credential-manager

Then do git-credential-manager github login to login with Github once and never have to enter your credentials in Gitnuro again (which is exactly what I wanted)