大佬教程收集整理的这篇文章主要介绍了node.js – Google Oauth提供代码兑换错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
TokenError: Code was already redeemed. at 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) at 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) at c:\Projects\Internship_rideshare\node_modules\passport-google-oauth\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:171:43 at 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 at 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) at 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) at Incomingmessage.emit (events.js:129:20) at _stream_readable.js:908:16 at process._tickCallBACk (node.js:355:11)
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 is already a Google+ account that belongs to you. Sign in with that account or delete it,then link it with your current account.' ); done(err); } else { User.findById(req.user.id,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 },exisTingUser) { if (exisTingUser) return done(null,exisTingUser); User.findOne({ email: profile._json.email },exisTingEmailUser) { if (exisTingEmailUser) { console.log('There is already an account using this email address. Sign in to that account and link it with Google manually from 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); }); } }); }); } }));
我被困在上面.请帮帮我……谢谢
以上是大佬教程为你收集整理的node.js – Google Oauth提供代码兑换错误全部内容,希望文章能够帮你解决node.js – Google Oauth提供代码兑换错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。