Google Oauth giving code redeemed error

前端 未结 4 401
甜味超标
甜味超标 2021-01-13 07:40

Hi i am working on a project where a user logs in via google account.(localhost) I have implemented the google signup. As soon as I log in from my account I am getting the b

4条回答
  •  别那么骄傲
    2021-01-13 08:29

    I have come across this issue. The exact problem is your route.

    app.get('/auth/google/callback', passport.authenticate('google'), (req, res) => {
       res.send('get the data');
    });
    

    At this point app had got user permission and google send a code to this url. Now what passport does here it took that code and made a request to google for user details and got it from google. Now we have to do something with this details otherwise you will get the error that you have got.

    Now we can use serialiseUser and deserialiseUser of passport to save details in cookie and edit one line of above code to go at some url like that.

    app.get('/auth/google/callback', passport.authenticate('google'), (req, res) => {
       res.redirect('/servey');  // just a url to go somewhere
    });
    

提交回复
热议问题