I'm attempting to use passport with an express/node.js app. For some reason I can't authenticate using google. Google gives the following error:
Error: invalid_request
Error in parsing the OpenID auth request.
Code:
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(user, done) {
done(null, user);
});
var GoogleStrategy = require('passport-google').Strategy;
var UserModel = require('./models/usermodel');
passport.use(new GoogleStrategy({
returnURL: 'http://localhost:3000/auth/google/return',
realm: 'http:/localhost:3000'
},
function(identifier, profile, done) {
profile.email = profile.emails[0].value;
UserModel.findOneAndUpdate({email:profile.email}, {$set:profile, $inc:{logins:1}}, {upsert:true}, done);
}
));
If you don't otherwise have reason to use OpenID, I highly recommend switching to OAuth 2.0, which is implemented in passport-google-oauth.
Google seems to be recommending that as their preferred authentication solution, and their OpenID implementation seems to receive less attention and spurious errors occur.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With