我创建了一个应用程序,客户端(vue)在 localhost:3000 上运行,服务器(express)在 localhost:8080 上运行。
我使用 passport-google-oauth20 策略使用 google 和仅 JWT 令牌登录。我的问题是: 如何在回调策略中重定向到客户端,以便接收有关客户端登录用户的信息?我在护照 jwt 中使用,我发送本地登录策略,一切正常。目前,在我看来是这样的:
this.router.get('/v1/auth/google',
passport.authenticate('google', { session: false, scope: ['email', 'profile']})
);
this.router.get('/v1/auth/google/callback',
passport.authenticate('google', { session: false }), (req, res) => {
// let token = sign(req.user);
res.redirect(`http://localhost:3000`);
// how to redirect to the CLIENT,
// who will receive data about the logged-in user?
// how get user data, catch this situation?
});