I have the following Node code using passport-google-oauth...
app.get(\'/auth/google\', passport.authenticate(\'google\', { scope : [\'profile\', \'email\'] }));
You didn't use "passport.authenticate('google')" middleware inside the second route '/auth/google/callback'.
your second route should be like :
app.get( '/auth/google/callback',
passport.authenticate( 'google', {
successRedirect: '/',
failureRedirect: '/login'
}));
i just found out that passport-google-oauth package exports the following:
exports.Strategy =
exports.OAuthStrategy = OAuthStrategy;
exports.OAuth2Strategy = OAuth2Strategy;
which means, that the "default" (ie. Strategy) is not oauth2 at all... So you better use OAuth2Strategy explicitly. it worked for me. Took me hours to find out this was the problem...