从节点中的github和bitbucket private repo下载zip

时间:2016-06-02 16:56:00

标签: node.js github bitbucket github-api

对于gitlab,我可以通过简单地使用http请求来下载节点中的私人仓库:

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

这对github和bitbucket也有可能吗?

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

我是否也可以使用私人令牌(如gitlab)进行此操作?

存储库是私有的!

1 个答案:

答案 0 :(得分:1)

您可以使用GitHub Contents API执行此操作。这个/get-archive-link资源会为您提供一个网址,然后您可以使用curl下载该文件。

  

我是否也可以使用私人令牌(如gitlab)进行此操作?

你可以而且你应该。使用personal access token repo生成scope

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

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