question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seeing 401 unauthorized errors when trying to clone private repo

See original GitHub issue

Hi! Firstly thanks for creating this library 😃

I’m new to this and unsure if I’m doing something wrong here, but I’m constantly seeing 401 errors when trying to clone a private repo of mine.

Here’s what I’m trying (in Chrome 83 on OSX 10.15):

<script src="https://unpkg.com/@isomorphic-git/lightning-fs"></script>
<script src="https://unpkg.com/isomorphic-git"></script>
<script type="module">
    import http from 'https://unpkg.com/isomorphic-git@beta/http/web/index.js'
    window.http = http;
</script>
let fs = new LightningFS('fs');
let pfs = fs.promises;
let dir = "/data";

await pfs.mkdir(dir);
await pfs.readdir(dir);

await git.clone(
  {
    fs: fs,
    http: window.http,
    dir: dir,
    corsProxy: 'https://cors.isomorphic-git.org',
    url: 'https://github.com/pickledish/private-repo',
    ref: 'master',
    username: 'pickledish',
    password: "valid-personal-access-token-123",
    singleBranch: true,
    depth: 10,
  }
);

But seeing this error:

GET https://cors.isomorphic-git.org/github.com/pickledish/private-repo/info/refs?service=git-upload-pack 401

I’ve verified that I’m able to pull public repos this exact way ^ without issue, and also verified via git clone https://github.com/pickledish/private-repo (in bash) that this particular username/token combo works, so I’m not sure where to go from here. If the answer is just to read some documentation, happy to read it, but haven’t been able to find anything about this in my searches.

Thanks in advance, lmk if I can add any more detail!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
koustubhgcommented, Jul 4, 2020

I am able to this using the following url

https://pickledish:valid-personal-access-token-123@github.com/pickledish/private-repo

and removing the username and password fields like this

await git.clone(
  {
    fs: fs,
    http: window.http,
    dir: dir,
    corsProxy: 'https://cors.isomorphic-git.org',
    url: 'https://pickledish:valid-personal-access-token-123@github.com/pickledish/private-repo,
    ref: 'master',
    singleBranch: true,
    depth: 10,
  }
);

Not sure if it’s the best way to do it, but it should be ok.

1reaction
mojavelinuxcommented, Feb 21, 2022

That’s correct. This is clearly documented in the documentation. See https://isomorphic-git.org/docs/en/onAuth. This was a change that came with isomorphic-git 1.x. Unless there is a specific question about those docs, I don’t think this issue should remain open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

git clone over https 401 error and not asking for username or ...
When I try to clone it on an Ubuntu server, it never asks me for a username or password and it fails with...
Read more >
Git clone in a job returns 401 unauthorized error - GitLab
When running git clone <repo> in a job via gitlab-runner, get 401 Unauthorized error: error: The requested URL returned error: 401 while ...
Read more >
HTTP 401 Unauthorized Error | What Is and How to Fix?
401 Unauthorized Error is an HTTP response status code indicating the request sent by the user couldn't be authenticated.
Read more >
401 Error: 5 Ways to Troubleshoot and Fix It - Hostinger
The 401 Unauthorized error indicates that the server's request was not verified because it lacks valid authentication credentials for the target ...
Read more >
"401 Unauthorized" error when cloning TFS git repository - Bugs
I received the following error when I tried to clone TFS git repository: <tfs_url>: 401 Unauthorized I did not find any other log...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found