简体   繁体   English

从github下载zip和节点中的bitbucket私有仓库

[英]Download zip from github and bitbucket private repo in node

For gitlab I can download a private repo in node by simple using making an http request to: 对于gitlab,我可以通过简单地使用http请求来在节点中下载私有仓库:

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

Is this also possible for github and bitbucket? github和bitbucket也可能吗?

I find a lot of curl scripts which use username and password to authenticate. 我发现很多使用用户名和密码进行身份验证的curl脚本。

Can I also do this simply with a private token (as in gitlab)? 我是否也可以使用私有令牌(如gitlab中)简单地做到这一点?

The repositories are private! 仓库是私人的!

You can do this using the GitHub Contents API . 您可以使用GitHub Contents API进行此操作。 This The /get-archive-link resources will provide you a URL that you can then use curl to download the file. /get-archive-link资源将为您提供一个URL,然后您可以使用curl来下载文件。

Can I also do this simply with a private token (as in gitlab)? 我是否也可以使用私有令牌(如gitlab中)简单地做到这一点?

You can and you should. 您可以而且应该。 Generate a personal access token with scope repo . 使用scope repo生成一个个人访问令牌

There's several ways to authenticate with the GitHub API. 使用GitHub API 进行身份验证的方法有多种。 I personally prefer to use the HTTP authentication fields: 我个人更喜欢使用HTTP身份验证字段:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM