永远不会调用 passport-facebook 策略回调函数

passport-facebook strategy callback function never gets called

我是passport新手,这里尝试使用passport-facebook策略进行身份验证。 但是 "FacebookStrategy" 中定义的回调函数永远不会被调用意味着 "Facebook callback called" 永远不会在控制台上打印。 虽然成功案例每次都运行。

这是我的代码

// Initialising passport
router.use(passport.initialize());

//router.use(passport.session()); /*I don't want to use passport session*/

passport.serializeUser(function (user, done) {
    done(null, user);
});

passport.deserializeUser(function (obj, done) {
    done(null, obj);
});

/**
 *  Configuring FacebookStrategy
 */
passport.use(new FacebookStrategy({
    clientID: 'facebook_client_id', // Facebook Client ID
    clientSecret: 'facebook_client_secret', // Facebook Client Secret
    callbackURL: 'https://sheltered-earth-74671.herokuapp.com/signin/facebook/callback' // Callback URL after user allow information access
}, function (accessToken, refreshToken, profile, done) { // Callback Function

    console.log('Facebook callback called'); /*THIS ISN'T PRINTING*/

    done(null, profile);
}));

router.get('/facebook', passport.authenticate('facebook', {
    scope: ['email']
}));

router.get('/facebook/callback', (req, res, next) => {
    res.send(req.query.code);  // This is working
});

谢谢

如文档所示:

更新回调函数为:

router.get('/facebook/callback', 
    passport.authenticate('facebook', 
    { successRedirect: '/', failureRedirect: '/login' }
)); 

See more here.