Oauth를 구현할려고 합니다. 아래와같이 작성했는데 failureRedirect 인 /login으로만 가지네요..
구글 로그인 페이지로 이동조차 안되는데 왜 안되는걸까요?
//구글 로그인
const GoogleStrategy = require('passport-google-oauth20').Strategy;
passport.use(
new GoogleStrategy({
clientID: '~~부여받은 아이디~~',
clientSecret: '~~부여받은 비밀번호~~',
callbackURL: 'http://localhost:8080/auth/google/callback',
},
function (request, accessToken, refreshToken, profile, done) {
console.log(profile);
return done(null, profile);
}
)
);
// 프로파일과 이메일 정보를 받는다.
app.get('/auth/google', passport.authenticate('google', { scope: ['profile', 'email'] }));
//? 위에서 구글 서버 로그인이 되면, redirect url 설정에 따라 이쪽 라우터로 오게 된다. 인증 코드를 박게됨
app.get('/auth/google/callback', passport.authenticate('google', {
successRedirect: '/userIndex',
failureRedirect: '/login',
failureFlash: true
}))
//==========================================