Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download Private Github Repo with Node.js Request module
var owner = "mbejda";
var repo = "somerepo";
var branch = "master"
var accessToken = "AccessToken";
var options = {
method: "GET",
url: `https://api.github.com/repos/${owner.toLowerCase()}/${repo.toLowerCase()}/tarball/${branch}?access_token=${accessToken}`,
headers: {
'Accept': 'application/vnd.github.v3.raw',
'User-Agent': 'mbejda.com'
}
};
request(options, function(error, response, body) {
if (error || response.statusCode !== 200) {
try {
console.log("failed to get repo ", response.statusCode);
} catch (e) {
}
///'Content-Type', 'application/zip'
console.log(error);
} else {
//// we got the repo!
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment