I used passportjs and passport-github to create a social login in my application,
passport.use(new GithubStrategy(
{
clientID : configAuth.githubAuth.clientID,
clientSecret : configAuth.githubAuth.clientSecret,
callbackURL : configAuth.githubAuth.callbackURL
},
function(token, refreshToken, profile, done) {
process.nextTick(function() {
User.findOne({'github.id' : profile.id}, function(err, user) {
if (err) {
return done(err);
}
if (user) {
return done(null, user);
} else {
var newUser = new User();
newUser.github.id = profile.id,
newUser.token = token,
newUser.name = profile.displayName;
newUser.email = profile.emails[0].value;
newUser.username = profile.username;
// save
newUser.save(function(err){
if (err) {
throw err;
}
return done(null, newUser);
});
}
});
});
}
));
Now I am using another component called octonode, which requires a access_token to authenticate its user, was the token in the callback the same as this access_token, because I do not seem like authenticated when doing this:
var github = require('octonode');
exports.read = function (req, res, next) {
var client = github.client();
client.get('/user?access_token=' + req.user.token, {}, function (err, status, body, headers) {
res.json(body);
});
};
And also tried doing this:
var client = github.client(req.user.token);
client.get('/user',{}, function...)
I get a blank screen, meaning no response.
req.user.tokenis actually returning the token value?