简体   繁体   中英

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:

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

Is this also possible for github and bitbucket?

I find a lot of curl scripts which use username and password to authenticate.

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

The repositories are private!

You can do this using the GitHub Contents API . This The /get-archive-link resources will provide you a URL that you can then use curl to download the file.

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

You can and you should. Generate a personal access token with scope repo .

There's several ways to authenticate with the GitHub API. I personally prefer to use the HTTP authentication fields:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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