1

I'll admit this is a bit of a duplicate of this question but I still cannot get a PAT token to work with Github and VS Code. I have tried following the solutions linked in that article, with no success. I'm not sure if I did something in my configuration while fighting with it to get it to work, but now I cannot even use it to push from the command line. I was able to make the same token work inside VS Code with the settings sync extension to synchronize the settings and it was accepted, but I cannot get it to work for the repo. I checked the permissions and it has access to admin:repo, gist, and repo permissions inside Github. I'm still pretty new to both, but I'm trying to get this functional so I can write better code the first time. When I try use authenticate I get the following error:

remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/.../....git/'

1 Answers1

0

I do make it work when the credentials are cached.

Meaning: putting aside VSCode for a moment, check if you can do a git ls-remote https://github.com/<yourAccount>/<yourPrivateRepo> with 2FA activated.

If your git config credential.helper is set "manager" on Windows, OSX Keychain on Mac), you should see a popup asking you for your credentials: enter your GitHub account and your PTA (Personal Token Access).

If the ls-remote works, then you can launch VSCode, which should be able to access the same repo, through the same URL.

In a Linux context, the OP Brian Hawkins confirms in the comments:

Adding PATH=%PATH%:/usr/share/doc/git/contrib/credential/libsecret git to my user profile did the trick!

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I tried setting the credential.helper and it added the line in the git config, but still doesn't function. I am on Linux, but I cannot find which file that is stored in to remove that key. It is now adding a error that it is not a valid command. Going to try wiping everything and starting from scratch tonight. It won't even accept the token from the command line now (probably from my trying several options and making it worse) – Brian Hawkins Mar 05 '19 at 18:57
  • @BrianHawkins What value did you set for the credential.helper? It should be libsecret: https://stackoverflow.com/a/40312117/6309 – VonC Mar 05 '19 at 21:17
  • Now it is giving me git: 'credential-secret' is not a git command. DId I configure something wrong? – Brian Hawkins Mar 06 '19 at 05:02
  • @BrianHawkins What is the value of `git config credential.helper` now? – VonC Mar 06 '19 at 09:01
  • [credential] helper = /usr/shar/doc/git/contrib/credential/libsecret/git-credential-libsecret
    that is the only value in .gitconfig
    – Brian Hawkins Mar 07 '19 at 04:24
  • For testing, can you add `/usr/shar/doc/git/contrib/credential/libsecret/` and just put `libsecret` in your `git config credential.helper`? – VonC Mar 07 '19 at 08:12
  • So here is the output when trying to do a push before modifying: git push origin master /usr/shar/doc/git/contrib/credential/libsecret/git-credential-libsecret get: 1: /usr/shar/doc/git/contrib/credential/libsecret/git-credential-libsecret get: /usr/shar/doc/git/contrib/credential/libsecret/git-credential-libsecret: not found I'm unsure where you were wanting me to add /usr/shar/doc/git/contrib/credential/libsecret at. I tried adding it as it's own line in the config and it said it was a bad config line. leaving libsecret gives git: 'credential-libsecret' is not a git command. – Brian Hawkins Mar 07 '19 at 12:39
  • @BrianHawkins Sorry, i coped your value, but that would be `/usr/share`, not `/usr/shar`. Basically, check your installation of Git on your Linux: it should come with `/usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret ` – VonC Mar 07 '19 at 12:48
  • @BrianHawkins " I'm unsure where you were wanting me to add /usr/shar/doc/git/contrib/credential/libsecret at": in the path: `PATH=%PATH%: /usr/share/doc/git/contrib/credential/libsecret git push` – VonC Mar 07 '19 at 12:49
  • @BrianHawkins Again, check first if `/usr/share/doc/git/contrib/credential/libsecret` folder does exist. – VonC Mar 07 '19 at 12:49
  • That does seem to have helped. I had to create a new token, but now it's trying. Still getting the error that "git: 'credential-secret' is not a git command." Seems like it's trying now though, because it's giving me a public email error, so I need to address that next. – Brian Hawkins Mar 08 '19 at 05:17
  • @BrianHawkins double-check your `$PATH`: "`git: 'credential-secret' is not a git command`" means: the executable `git-credential-secret` is not in your `$PATH`. – VonC Mar 08 '19 at 07:41
  • Adding PATH=%PATH%: /usr/share/doc/git/contrib/credential/libsecret git to my user profile did the trick! Now I just have to fix the email privacy error and I'm all good! Thank you!!!! – Brian Hawkins Mar 13 '19 at 04:02
  • @BrianHawkins Great, well done! Just to be sure, why is there a space before '`git`' in `/usr/share/doc/git/contrib/credential/libsecret git `? Is '` git`' part of the `%PATH%`? – VonC Mar 13 '19 at 07:18
  • my actual line in my %PATH% is PATH=%PATH%: /usr/share/doc/git/contrib/credential/libsecret git push . Is it not supposed to have anything after libsecret? – Brian Hawkins Mar 19 '19 at 03:57