node.js - Google Oauth giving code redeemed error -


hi working on project user logs in via google account.(localhost) have implemented google signup. log in account getting below error.

tokenerror: code redeemed.        @ strategy.oauth2strategy.parseerrorresponse (c:\projects\internship_rideshare\node_modules\passport-google-oauth\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:298:12)        @ strategy.oauth2strategy._createoautherror (c:\projects\internship_rideshare\node_modules\passport-google-oauth\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:345:16)        @ c:\projects\internship_rideshare\node_modules\passport-google-oauth\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:171:43        @ c:\projects\internship_rideshare\node_modules\passport-google-oauth\node_modules\passport-oauth\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:176:18        @ passbackcontrol (c:\projects\internship_rideshare\node_modules\passport-google-oauth\node_modules\passport-oauth\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:123:9)        @ incomingmessage.<anonymous> (c:\projects\internship_rideshare\node_modules\passport-google-oauth\node_modules\passport-oauth\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:142:7)        @ incomingmessage.emit (events.js:129:20)        @ _stream_readable.js:908:16        @ process._tickcallback (node.js:355:11) 

my code follows(snippet google login):-

passport.use(new googlestrategy(google, function(req, accesstoken, refreshtoken, profile, done) {   if (req.user) {     user.findone({ google: profile.id }, function(err, existinguser) {       if (existinguser) {         console.log('there google+ account belongs you. sign in account or delete it, link current account.' );         done(err);       } else {         user.findbyid(req.user.id, function(err, user) {           user.google = profile.id;           user.tokens.push({ kind: 'google', accesstoken: accesstoken });           user.profile.displayname = user.profile.displayname || profile.displayname;           user.profile.gender = user.profile.gender || profile._json.gender;             //user.profile.picture = user.profile.picture || 'https://graph.facebook.com/' + profile.id + '/picture?type=large';           user.save(function(err) {             console.log('google account has been linked.');             done(err, user);           });         });       }     });   } else {     user.findone({ google: profile.id }, function(err, existinguser) {       if (existinguser) return done(null, existinguser);       user.findone({ email: profile._json.email }, function(err, existingemailuser) {         if (existingemailuser) {            console.log('there account using email address. sign in account , link google manually account settings.' );           done(err);         } else {           var user = new user();           user.email = profile._json.email;           user.google = profile.id;           user.tokens.push({ kind: 'google', accesstoken: accesstoken });           user.profile.displayname = profile.displayname;           user.profile.gender = profile._json.gender;             //user.profile.picture = 'https://graph.facebook.com/' + profile.id + '/picture?type=large';           user.profile.location = (profile._json.location) ? profile._json.location.name : '';           user.save(function(err) {             done(err, user);           });         }       });     });   } })); 

i stuck on it.please me out..thanks

the problem not in "snippet", @ routes. should absolute path on redirect google.

router.get('/auth/google/callback', passport.authenticate('google', { failureredirect: '#/signin' }), function(req, res) { // absolute path     res.redirect('http://localhost:8888/#/home'); }); 

it's known issue, follow link other workarounds https://github.com/jaredhanson/passport-google-oauth/issues/82


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -