can anyone help me with this issue? the callback never ends. I have followed passport facebook guide and passport-facebook guide and both have the same problem. Here is my code:
passport.use(new FacebookStrategy({
clientID: FACEBOOK_APP_ID,
clientSecret: FACEBOOK_APP_SECRET,
callbackURL: "http://localhost:3000/auth/facebook/callback"
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ facebookId: profile.id },{name:profile.displayName},
function (err, user) {
return done(err, user);
});
}
));
app.get('/auth/facebook', passport.authenticate('facebook'));
app.get('/auth/facebook/callback',
passport.authenticate('facebook', { failureRedirect: '/error',
successRedirect: '/success' }));
Configuration and dependencies
node.js version 0.10
"express": "3.2.1",
"passport": "0.1.16",
"passport-facebook": "0.1.5",
"paypal-ipn": "1.0.1",
"ejs": "0.8.3",
"sequelize": "1.7.0-alpha1",
"winston": "0.7.1",
"mysql": "2.0.0-alpha8"
Sequelize methods like findOrCreate() don't accept a callback function to handle results, but return a promise-like object:
User.findOrCreate(
{ facebookId : profile.id },
{ name : profile.displayName}
).success(function(user) { // called when findOrCreate was successful
done(null, user);
}).error(function(err) { // called when findOrCreate failed
done(err);
});
Alternatively, you can use complete or done as a shortcut (they use the same err, result signature as the Strategy's done method, so you can pass that in directly):
User.findOrCreate(
{ facebookId : profile.id },
{ name : profile.displayName}
).complete(done);
// or
User.findOrCreate(
{ facebookId : profile.id },
{ name : profile.displayName}
).done(done);
In your case, the callback you provide to findOrCreate() is never called and the done() function of the Strategy callback is never called.