octonode icon indicating copy to clipboard operation
octonode copied to clipboard

Checking organization member does not work correctly.

Open Cicko opened this issue 7 years ago • 2 comments

I am using passport for authentication and when I want to check if the authenticated user is member of a github organization it always return a false. I was also trying to get all members of that organization and it only returns a ONE member. Here you see my code:

passport.use(new Strategy({
  clientID: oauth_file.clientID,
  clientSecret: oauth_file.clientSecret,
  callbackURL: oauth_file.callbackURL
},
function(accessToken, refreshToken, profile, done) {
  var org = require('./.config.book.json').organization;

  var client = github.client(accessToken);
  var ghorg = client.org(org);
  ghorg.member(profile.username, (err,result) =>
  {
    if(err) console.log(err);

    console.log("Result: " + result); // Always is FALSE
    if(result == true)
      done(null, profile);
    else
      done(null, null);
  });
}));

When I try to get all members doing this:

  ghorg.members((err, result) => {
    if (err) console.log(err);
    else console.log(result);
  })

It always returns only ONE member.

I was now investigating little and I can see that I can not see the other members because they are private.. So I have to be logged to my account and I imagine that with the accessToken returned by the Passport Strategy should be enought to be log in.

Cicko avatar Jul 19 '17 14:07 Cicko

Unfortunately, I have no idea about passport usage and can't help you with debugging. Please update me if you find out the issue.

pksunkara avatar Jul 19 '17 14:07 pksunkara

Ok. I will still looking for the solution. Thanks for the fast answering. Have a good day

Cicko avatar Jul 19 '17 14:07 Cicko