I have an app that recovers licenses according to the repos of my organization. But I'm currently having problems getting them, since it returns 404 error and no license. From what I saw it is a matter of having to authenticate the app on github so that it allows you to make more than 60 requests per hour. The only example that GitHub puts is link
and my problem with this is that there is no example in nodejs and I am somewhat new to this language. If someone could give me a hand or guide me more or less how to authenticate my app.
getFromGithub: function(allRepos, callback){
var self = this;
console.log(self.settings.gitToken);
var apiRequest = api('/repos/' + self.settings.org + '/' + self.repo + '/contents/package.json', {
token: self.settings.gitToken
});
apiRequest.on('data', function(response) {
self.reposParsed = JSON.stringify(allRepos);
var packageJSON = new PackageJSON(self.settings, self.reposParsed);
packageJSON.parseFromString(response.content, function(){
//Log the requests of proyect.
const output = fs.createWriteStream('./stdout.log');
const errorOutput = fs.createWriteStream('./stderr.log');
const logger = new Console(output, errorOutput);
logger.log(res);
self.getLicenseTree(packageJSON, function(err){
if(err)
return callback(err, null);
self.licenses = packageJSON.list;
callback(null, self.licenses);
});
});
});
apiRequest.on('error', function(err) {
console.log(err);
callback(err, null);
});
},
And this is the code where they are obtained.