Passport回调未称为Google API

时间:2018-07-07 14:41:34

标签: callback google-api passport.js google-login

我在我的Web应用程序中有google登录/注册,并按照https://github.com/jaredhanson/passport-google-oauth2的示例操作 由于某些奇怪的原因,策略回调未触发,并且用户界面在登录后陷入卡住/停留在加载中。 以下代码未执行-

console.log("strategy");

        return done(null, profile);

//Google login
router.get('/google', passport.authenticate('google', {
    scope: [
        'profile'
    ]
}));

//Google Redirect Handler passport.authenticate('google'),
router.get('/google/redirect', passport.authenticate('google', { failureRedirect: '/login' }), (req, res) => {
    console.log('gg');
    res.redirect('/');
});

passport.use(
    new GoogleStrategy({
        clientID: keys.google.clientID,
        clientSecret: keys.google.clientSecret,
        callbackURL: 'http://localhost:4200/api/auth/google/redirect'
    }, (accessToken, refreshToken, profile, done) => {

        console.log("strategy");

        return done(null, profile);
    })
)

0 个答案:

没有答案