I am currently working on a project that allows me to work with 2 Github accounts (work / private). I am building a NodeJS CLI that takes a username as a parameter and updates the following values accordingly:
git config --global user.name USERNAME
git config --global user.email EMAIL
Updates Windows credential manager with the following values:
USERNAME, PERSONAL-ACCESS-TOKEN
The email and personal access token are stored safely, and retrieving them is not the problem here. I am using Windows Credential Manager to store my Git credentials, but when I look into my Credential Manager, I have 2 separate entries that can be used for GitHub authentication:
vscodevscode.github-authentication/github.auth
-->username: github.auth
git:https://github.com
-->username: PERSONAL USERNAME
I understand that since a short while, Github is using tokens to authenticate its users. And that the preferred way of storing these credentials is with the URL-syntax (https://USERNAME:PAT@github.com/LINK_TO_REPO
), but this only works per repository. I am looking for 1 command to change the Git authentication (for GitHub) globally.
So is it possible for VS Code (I am using GitLens plugin, and VS Code authenticates itself to GitHub) to use a custom username + Personal Access Token stored in a file somewhere, instead of the github.auth
account credentials? Or for that matter, stored in Windows Credential Manager, where I have access to read and edit them?
And does GitHub accept the Personal Access token if Windows Credential Manager stores / passes it as a password?