Question

In the below code the 'console.log('this does not print!')' statement does not execute. It should execute according to the FacebookStrategy.

passport.use( new FacebookStrategy({clientID: FACEBOOK_APP_ID, clientSecret: FACEBOOK_APP_SECRET, callbackURL: "/home"}, function(identifier, profile, done) {

process.nextTick(function () {
  console.log(' This does not print!');
  return done(null, profile);
  }
);}));

Basically, the authentication thru passport-facebook takes place but I am not able to recover any profile data.

app.get('/home', function(req, res){
    console.log(req.user);
    res.render('home', {user: req.user});
});

The above prints 'undefined' which means that the above app.get(...) did not receive the facebook profile data.

What am I doing wrong? Is there anyway to save (get) facebook profile data after authentication?

Était-ce utile?

La solution

Above

callbackURL: "/home"

is wrongly declared. It should be:

callbackURL: "/auth/facebook/callback"

for more on this discussion https://github.com/jaredhanson/passport-facebook/issues/47

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top