通过Google护照登录并带有js密码

问题描述 投票:0回答:1

[我已经使用passport-google-oauth20为具有nodejs + passport的应用程序构建了API,>

这是我使用的护照策略


passport.use(new GoogleStrategy({
    clientID: config.google.clientId,
    clientSecret: config.google.clientSecret,
    callbackURL: config.google.redirectUri
},
function (accessToken, refreshToken, profile, cb) {
    User.findOne({ googleId: profile.id }).exec(function (err, user) {
        if (err) return console.log('ERROR ' + err)
        if (user) {
            console.log('User authenticated ' + `${user.email}`.blue)
            return cb(err, user)
        } else {
            let newUser = new User({
                googleId: profile.id,
                email: profile.emails[0].value,
                name: profile.name.givenName,
                surname: profile.name.familyName,
                picture: profile.photos[0].value
            })
            newUser.generateToken()
            newUser.save(function (err, obj) {
                if (err) {
                    console.log('Error saving a new user: '.red + err)
                }
                console.log('New user ' + `${obj.email}`.blue)
                return cb(err, obj)
            })
        }
    })
}))

这些是登录用户的路由

    router
        .route('/auth/google')
        .get(passport.authenticate('google', { scope: ['profile', 'email'] }))

    router
        .route('/auth/google/callback')
        .get(
            passport.authenticate('google', { failureRedirect: '/auth' }),
            (req, res) => {
                return res.send(sanitize.clean(req.user))
            }
        )

但是现在我正在用Flutter构建前端,并且我试图在嵌入式浏览器中通过Google进行身份验证,但我发现google disabled them

如何从应用程序向Google进行身份验证,但仍连接后端?

我已经使用passport-google-oauth20为使用nodejs + passport的应用程序构建了API,这是我使用的passport策略。use(new GoogleStrategy({clientID:config.google.clientId,...

ios node.js flutter passport.js google-authentication
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.