Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Malte0621 opened this issue Jul 8, 2023 · 4 comments
Labels

Comments

@Malte0621
Copy link

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).

@steveukx
Copy link
Owner

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 #424 (comment)) to ensure the token is being passed through to git correctly.

@steveukx steveukx added more-info-needed More information is required in order to investigate question labels Jul 17, 2023
@Malte0621
Copy link
Author

Malte0621 commented Jul 17, 2023

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

@github-actions github-actions bot removed the more-info-needed More information is required in order to investigate label Jul 17, 2023
@Malte0621
Copy link
Author

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..)

@schettn
Copy link

schettn commented Dec 17, 2024

If someone stumbles upon this issue, you have to use basic instead of bearer and base64 encode the token.

const b64Token = Buffer.from(args.token).toString('base64');

const git = simpleGit({
  baseDir: projectPath,
  config: [`http.extraHeader=Authorization: Basic ${b64Token}`],
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants