I use node.js in my project and try to make the site can be signed in with google, but after choosing the email(account), it redirect to th right page successfully but without signing in.
passport.js:
passport.use(new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: "http://localhost:4000/auth/google/callback",
passReqToCallback: true
},
function (request, accessToken, refreshToken, profile, done) {
done(null, profile);
}
));
index.js:
router.get('/auth/google',
passport.authenticate('google', {
scope: ['email', 'profile']
}
));
router.get('/auth/google/callback',
passport.authenticate('google', {
session: false,
failureRedirect: 'signup' }),
(req, res) => {
res.redirect('/')
});
If I put : 'session:true' an error occurs: The result:
[nodemon] app crashed - waiting for file changes before starting...
I cann't know what is happening, the redirect is successful to the page http://localhost:4000/ but it doesn't open because [nodemon] app crashed, and
when set session: false, no error occurs but without signing in.
Top comments (2)
thanks for this blog!
Thank you!