github icon indicating copy to clipboard operation
github copied to clipboard

Unable to access stored credentials

Open hectorsector opened this issue 9 years ago • 17 comments

Hi friends 👋

I'm so excited about the GitHub Package! I seem to be unable to access cached credentials within the UI. I've been using an personal access token because I have 2FA enabled, but it's my understanding that it's not how it's supposed to work.

I get this error message whenever I perform a fetch.

git: 'credential-osxkeychain' is not a git command. See 'git --help'. fatal: could read Username for 'https://github.com': Device not configured

Sometime a pull/push works. However, it doesn't ever remember the credentials and I have to type them in every time. Do I have some wonky settings or is this a bug? Thank you!

Versions

Atom Version (atom --version): Atom : 1.13.0

GitHub Package Version (git --git-dir ~/.atom/packages/github/.git rev-parse head): bea2da8b554d8528dae3065a2917aec8aab05570

hectorsector avatar Jan 13 '17 00:01 hectorsector

Same thing, it asks me for my credentials every time I push, and doesn't even mention the osx keychain. Is there a setting I need to enable?

cmrberry avatar Jan 23 '17 21:01 cmrberry

#597 will help with this, somewhat - if your native credential handler fails, you'll be prompted through Atom.

Atom won't automatically remember credentials for you, though (yet). To do that, you'll want to install the git osxkeychain credential helper mentioned in the error message; it's included in homebrew's version of git. To be used, it needs to be on your ${PATH}:

$ which git-credential-osxkeychain

And it needs to be set in your git configuration:

$ git config --get-all credential.helper
# If it's not there:
$ git config --global credential.helper osxkeychain

smashwilson avatar Mar 16 '17 20:03 smashwilson

Thanks @smashwilson! My own issue seems to have been resolved so I am closing it out. @cmrberry please feel free to reopen if it still doesn't work for you.

hectorsector avatar Mar 20 '17 17:03 hectorsector

Same thing here, how did you resolve this ?

Every time i make Pull, Push or Fetch, the Atom requires my username and password

mauriciord avatar May 23 '17 13:05 mauriciord

@mauriciord Are you interacting with a remote over an https or ssh URL?

For https remotes, you'll want to install a credential helper that will store accepted usernames and passwords in your OS keychain. (The specifics on configuring this vary on different platforms.)

For ssh remotes, you'll want to configure an ssh agent or (if you're also using GPG signing) a gpg agent.

As a side benefit, this will also work for remote operations on the command-line :smile:

smashwilson avatar May 23 '17 14:05 smashwilson

Hey @smashwilson thanks for the help, it's a https remote, but i've already did this. In VSCode and Terminal, i'm using normally without typing everytime the user and password. Why only in Atom this is not working ?

mauriciord avatar May 23 '17 16:05 mauriciord

When i type:

git config --get-all credential.helper

Outputs this: screen shot 2017-05-23 at 14 22 58

Sorry for the noob question, but why 2 osxkeychain ?

mauriciord avatar May 23 '17 17:05 mauriciord

Why only in Atom this is not working ?

Good question!

Can you enable "git diagnostics" in the GitHub package settings, reproduce, then open your dev tools and expand the git -c gpg.program=... commit section in your console? That will enable GIT_TRACE and capture some information that would be helpful for seeing why your credential helper isn't being invoked correctly.

Sorry for the noob question, but why 2 osxkeychain ?

I suspect one is from your system configuration and one is from your global git configuration. You can use EDITOR=echo git config --system --edit to see where your system config is (if you have git installed from homebrew, it's likely under some /usr path).

smashwilson avatar May 23 '17 22:05 smashwilson

HEY @smashwilson ,

Can you enable "git diagnostics" in the GitHub package settings, reproduce, then open your dev tools and expand the git -c gpg.program=... commit section in your console? That will enable GIT_TRACE and capture some information that would be helpful for seeing why your credential helper isn't being invoked correctly.

I made this and: git-Cgpg.txt

I used EDITOR=echo git config --system --edit and my terminal output this: /private/etc/gitconfig

mauriciord avatar Jun 08 '17 21:06 mauriciord

@mauriciord Excellent, thanks for the trace. I'll have a look in more detail soon.

I'm wondering if I'm passing the wrong PATH to that git invocation somehow, since git credential-osxkeychain is on your shell path... 🤔

smashwilson avatar Jun 08 '17 22:06 smashwilson

Hmm, I have a hunch. When git executes internal processes, it prepends an exec path where the git binaries live. Dugite sets the exec path to its own, bundled tools when it runs git commands. I'm wondering if the git-credential-osxkeychain binary is in the exec path for your native git install and also not on your system path. That would explain why your command-line git can find it but the dugite-managed git cannot, even with the same PATH.

From your git system path, it also looks like you're using the macOS system git rather than a homebrew install like I'm using. I'm betting homebrew puts the exec path on PATH as well which explains why it's working for me :wink:

Can you share the output from these commands to confirm:

  • git --exec-path
  • echo ${PATH}
  • which git-credential-osxkeychain

smashwilson avatar Jun 09 '17 01:06 smashwilson

Of course @smashwilson ,

  • git --exec-path
  • echo ${PATH}
  • which git-credential-osxkeychain

git --exec-path /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

echo ${PATH}

/Users/mauricio/Documents/google-cloud-sdk/bin:/usr/local/heroku/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/mauricio/.rvm/bin

which git-credential-osxkeychain Does not output anything

mauriciord avatar Jun 09 '17 11:06 mauriciord

Ah ha! Yep, that's what's going on. A tentative solution: we can attempt to gather the exec path from a native git install and append it to the ${PATH} we use for git operations.

As a temporary workaround you should be able to run:

export PATH=${PATH}:$(git --exec-path)

And relaunch Atom.

smashwilson avatar Jun 09 '17 12:06 smashwilson

@smashwilson running that did not work for me.

I had to add export PATH=${PATH}:$(git --exec-path) to ~/.bash_profile.

jaydenseric avatar Jun 20 '17 04:06 jaydenseric

I had to add export PATH=${PATH}:$(git --exec-path) to ~/.bash_profile.

I had to add too @jaydenseric

Working now :)

mauriciord avatar Jun 26 '17 20:06 mauriciord

➜  ~ git --exec-path
/usr/local/git/libexec/git-core
➜  ~ echo ${PATH}
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
➜  ~ which git-credential-osxkeychain
/usr/local/bin/git-credential-osxkeychain
➜  ~ git config --get-all credential.helper
osxkeychain

~/.bash_profile

export PATH=${PATH}:/mongodb-osx-x86_64-3.4.0/bin;
# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
export PATH=${PATH}:$(git --exec-path)

it doesn't work for me,is anyone can help?thank you !

openks avatar Jul 05 '17 09:07 openks

Word to the wise, if you follow the other tickets you'll just end up back here.

jonnylink avatar Aug 22 '17 13:08 jonnylink