I tried to hit my git hub API to get some data. I have my Client ID and Client Secret. Code which I tried put is below:
var GitHubApi = require('github');
var github = new GitHubApi({
version: "3.0.0",
debug: true,
protocol: "https",
host: "api.github.com",
timeout: 5000,
authenticate: {
type: "oauth",
key: process.env['GITHUB_CLIENT_ID'],
secret: process.env['GITHUB_CLIENT_SECRET']
}
});
and
hitting API with :
loadUserFromServer2 : function (username){
github.user.get({
user: username,
},function(err,res){
if(err){
console.log(err);
}
console.log(JSON.stringify(res));
});
}
I am getting the error that (..)
{ [Error: {"message":"Requires authentication","documentation_url":"https://developer.github.com/v3"}] [error] (..), code: 401 }
What am I missing in my authorization ?
It still does not work. I was able to have the access as a normal user.
My code is :
github.authorization.create({
"scopes" : ["user"],
"note" : "admin server rights",
"type" : "oauth",
"app": {
"name" : "gitHubNetwork",
"client_id" : process.env['GITHUB_CLIENT_ID'],
"client_secret" : process.env['GITHUB_CLIENT_SECRET']
}
});
But I am still getting below reply:
{ [Error: {"message":"Requires authentication","documentation_url":"https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api"}]
console.logingprocess.env.GITHUB_CLIENT_IDandprocess.env.GITHUB_CLIENT_SECRETto ensure that they are set to the proper values? - Travis Kaufman