Last active
March 17, 2024 04:32
-
-
Save mbejda/fa0f56366a3e388d490dabf46298cb2a to your computer and use it in GitHub Desktop.
Download Private Github Repo with Node.js Request module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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