简体   繁体   中英

Passportjs Google OAuth20 not working when deployed on digital ocean

I have set up a server on the digital ocean and deployed my react application on it. But somehow my Passportjs Google OAuth is not working, but it is working fine when I run it locally, it redirects to callback URL perfectly.

I thought the problems were of node version but I updated node on the server too but still didn't solve.Node -v is 10.15

passport.serializeUser((id, done) => {
  done(null, done)
})

passport.use(
  new GoogleStrategy({
    clientID: keys.google.clientID,
    clientSecret: keys.google.clientSecret,
    callbackURL: prod ? 'http://knowankit.com/myself-in-detail' : 'http://knowankit.com/myself-in-detail'
  }, (request, accessToken, refreshToken, profile, done) => {
    console.log('Testing ')
    done(null, true)
  })
)

The website is https://knowankit.com . Login screen - https://knowankit.com/know-me . When you click on user-lock icon it redirects to google login after login it redirects to the homepage. Any help would be really appreciated. I have been stuck on this for a month.

I was able to solve this. This was my mistake as in the Google OAuth the localhost:3000 was added as trusted URL but when it is deployed then deployed URL also needs to be added as trusted URL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM