我在 ExpressJS Web 应用程序中使用 PassportJS。
在 app.js 中:
//passportjs google
passport.use(new GoogleStrategy({
clientID: '...',
clientSecret: '...',
callbackURL: '...'
}, user.oauth2Login
));
app.get('/auth/google',
passport.authenticate('google', { scope: 'email' }));
app.get('/auth/google/callback',
passport.authenticate('google', { successReturnToOrRedirect: '/home', failureRedirect: '/login' }))
在我的用户模块中:
exports.oauth2Login = function(accessToken, refreshToken, profile, done) {
//get ip here
}
如何在oauth2Login
中获取用户的IP?
最佳答案
关于node.js - 在 PassportJS/ExpressJS 中获取 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17871096/