从 github 下载 zip 和 bitbucket private repo in node

Download zip from github and bitbucket private repo in node

对于 gitlab,我可以通过简单地使用向以下地址发出 http 请求来在节点中下载私有存储库:

"https://" + host + "/" + group + "/" + project + "/repository/archive.zip\?ref\=" + branch + "\&\private_token\=" + private_token;

这也适用于 github 和 bitbucket 吗?

我发现很多使用用户名和密码进行身份验证的 curl 脚本。

我也可以使用私有令牌(如在 gitlab 中)来简单地做到这一点吗?

存储库是私有的!

您可以使用 GitHub Contents API 执行此操作。此 /get-archive-link 资源将为您提供 URL,然后您可以使用 curl 下载文件。

Can I also do this simply with a private token (as in gitlab)?

你可以而且你应该这样做。生成一个personal access token with scoperepo.

to authenticate GitHub API 有多种方式。我个人更喜欢使用 HTTP 身份验证字段:

https://USER@TOKEN:api.github.com/...