git-js icon indicating copy to clipboard operation
git-js copied to clipboard

Cloning with personal access token causing "remote: invalid credentials".

Open Malte0621 opened this issue 2 years ago • 3 comments

Code:

const git = simpleGit.simpleGit({
  baseDir: localPath,
  binary: "git",
  maxConcurrentProcesses: 6,
  config: [
    `http.extraHeader=Authorization: Bearer ${TOKEN}`,
  ],
});

git
.clone(cloneURL, localPath)
.then(() => {
  returnPromise(true);
})
.catch((err) => {
  console.error(err);
  returnPromise(false);
});

Issue:

After running the code a github credentials prompt pops up, every time.. Even tho the token is provided in the config. image Upon closing OR filling in the prompt, the following shows: image

I just recently created the token, with access to all of my repositories (read-only).

Malte0621 avatar Jul 08 '23 10:07 Malte0621

Hi, the extract you've included does look correct... how are you setting TOKEN?

I recommend you run with verbose logging enabled, or use the GIT_TRACE environment variable (see https://github.com/steveukx/git-js/issues/424#issuecomment-590270247) to ensure the token is being passed through to git correctly.

steveukx avatar Jul 17 '23 18:07 steveukx

I ran it with full verbose and this is all that shows up. image

Malte0621 avatar Jul 17 '23 20:07 Malte0621

Seems like its trying to read from some kind of file? Also, /dev/tty isn't valid .-. (Probably because I'm testing it on windows atm..)

Malte0621 avatar Jul 17 '23 20:07 Malte0621