JR *_*lia 2 node.js express passport.js
我在 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' }))
Run Code Online (Sandbox Code Playgroud)
在我的用户模块中:
exports.oauth2Login = function(accessToken, refreshToken, profile, done) {
//get ip here
}
Run Code Online (Sandbox Code Playgroud)
如何获取用户的IP oauth2Login?
| 归档时间: |
|
| 查看次数: |
2390 次 |
| 最近记录: |