PassportJS와 passport-google-oauth20
을 사용하여 Google에 로그인하면 애플리케이션에서 요청을 완료하지만 Passport는이를 인식하지 않고 대신 오류를 호출합니다.PassportJS Google 로그인이 잘못되었지만 성공 중입니다.
test point 1
undefined
을하지만 브라우저를 확인할 때, 그것은 500를 반환
router.get('/auth/google/callback',
passport.authenticate('google', {failureRedirect: '/login'}),
(req, res) => console.log(req),
(err, req, res, next) => {
console.log('test point 1')
console.log(err.stack)
return res.status(500).send(err)
})
출력은 요청이 I를하지 않았 음을 나타내는 다음과 같습니다 믿는
:내 코드는 다음과 같습니다 코드 예 : 올바른 Google 사용자 정보 (예 : 프로필 사진 및 ID) Passport는이 값을 req.user
변수에 저장하지 않습니다. 감사!
// TODO: eventually setup user account system
passport.serializeUser((user, done) => done(null, user))
passport.deserializeUser((obj, done) => done(null, obj))
// TODO: eventually use this to associate the users account
passport.use(new GoogleStrategy({
callbackURL: 'http://localhost:8080/api/v0/auth/google/callback',
clientID: 'number-id.apps.googleusercontent.com',
clientSecret: 'secrets'
}, (accessToken, refreshToken, profile, cb) => {
cb(profile)
}))
내 상황에 대해 다를 것이라고 생각할 수있는 유일한 것은 내가 특정에서만 use
보내고 여권을 해요이다 : 그것은 유용 경우
, 내 여권 초기화는 아주 간단하고 명확하다 경로 집합입니다. (예 : API)