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,
}
);
md5-2468e776d0c419bbf668da6ad712f456
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!
I am able to this using the following url
https://pickledish:[email protected]/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:[email protected]/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.
Ah, wow good tip @koustubhg confirmed that worked for me too! I wonder what kind of bug was introduced here, wish I knew more JS 馃
Also encountered this bug today. But thanks to @koustubhg's solution, the workaround worked pretty well! 馃帀
Most helpful comment
I am able to this using the following url
https://pickledish:[email protected]/pickledish/private-repoand removing the
usernameandpasswordfields like thisNot sure if it's the best way to do it, but it should be ok.