Passport.jslogin事件function没有被调用

我用护照快递使用以下代码:

var GAuth = require('passport-google-oauth'); passport.use('google', new GAuth.OAuth2Strategy({ clientID: GID, clientSecret: GSECRET, callbackURL: "http://localhost:3000/auth/google/callback" }, function(accessToken, refreshToken, profile, done){ // not running console.log('callback'); console.log('id: ', profile.id); })); router.get('/google', passport.authenticate('google', { scope: [ 'email', 'profile' ] })); router.get('/google/callback', function(req, res) { // this runs res.send('Logged in through Google!'); }); 

即使login似乎在外面工作正常,因为我去到谷歌的权限页面,然后被定向到callback页面。 我不能得到callback函数运行,所以我做错了什么?

你不应该在路由器中为“/ auth / google / callback”定义一个POST吗?

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

这应该工作。