Skip to content

Instantly share code, notes, and snippets.

@mbejda
Last active March 17, 2024 04:32
Show Gist options
  • Save mbejda/fa0f56366a3e388d490dabf46298cb2a to your computer and use it in GitHub Desktop.
Save mbejda/fa0f56366a3e388d490dabf46298cb2a to your computer and use it in GitHub Desktop.
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