As I read at Creating a personal access token
and Where to store the personal access token from GitHub? I understand that Git requires from the user on the local machine at first use to enter PAT and then stores it with Windows Credentials Manager
if Windows or credentialStore
for Linux/MacOS.
I created a Nodejs app that use nodegit
(libgit2
) to fetch or clone a git repository. For doing so, I need to provide a PAT. I tried to get the PAT from Windows Credentials Manager
but couldn't find an npm package that works to do so.
What is the best practice to get the PAT for app use that use Git?
Should I get it as I said in the first paragraph from the local machine using Windows Credentials Manager
or credentialStore
, or should I prompt the user to enter the PAT once and save it? If so, how should I save it? It will be unsafe to save the PAT in plain text as is. And where the file which I'm saving the PAT should be located? C:/users/USER
or in the repository directory and add the file to .gitignore
?