Search code examples
macosgithubcommand-lineaccess-tokenkeychain

Personal Access Token in Github not working


I have a private repository on my personal Github account that I work on from time to time, but not on a daily basis.

The repository has been cloned using HTTPS (not SSH or git://). In order to access the repository from the command line, I set up a personal access token as explained here: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

I am positive it did work back then (I moved away from SSH precisely because this kind of persistent headache).

However, when I try to push to my repository after a few weeks I get the dreaded:

$ remote: Repository not found. fatal: repository
$ 'https://github.com/nicolas-miari/MyPrivateRepo.git/' not found

What am I missing?


Addendum: I deleted the token on Github, created a new one, and followed the instructions here: https://help.github.com/articles/updating-credentials-from-the-osx-keychain/ to clear the old token stored in the keychain. I was able to re-clone my private repository. However,

  1. This still doesn't explain why the previous access token suddenly stopped working, and

  2. My keychain had two "Internet password" entries matching the host github.com: The access token I just deleted, and the my web login password for a different Github account (work). Maybe this has something to do with it?

Background info: To avoid having to log in/out frequently, I have my work account's web credentials saved in Safari (and the Keychain), and my personal account's web credentials saved in Firefox.


Addendum 2: After running the command given on the linked help page:

$ git credential-osxkeychain erase
  host=github.com
  protocol=https
  [enter]

...the additional password is gone from the Keychain (only my newly added Personal Token remains), however I can still log in to my account on Safari...?


Update: Now I can't push to repos from my work account (which credentials I deleted from Keychain...). This system really needs a healthy dose of Just Works...


Solution

  • Don't forget that Safari has access to iCloud Keychain

    That could explain why, even though you have cleared your local OSX keychain, you still can log on to GitHub with Safari.