jaredhanson / passport

Simple, unobtrusive authentication for Node.js.
https://www.passportjs.org?utm_source=github&utm_medium=referral&utm_campaign=passport&utm_content=about
MIT License
22.91k stars 1.24k forks source link

Google passport authentication error: Code was already redeemed #654

Open prabhakarupadhyay opened 6 years ago

prabhakarupadhyay commented 6 years ago

Im getting problem regarding google passport login on google cloud platform.After successful google authentication the screen keeps loading and is unable to redirect to the website again. Im able to trace the google auth callback in the logs but somehow i just cant catch it in the server application. My code for the authentication and callback is correct as it works fine in the localhost and other cloud platform(openshift) where i tried hosting my node application.

this is the error i get in the /auth/google/callback :

TokenError: Code was already redeemed. at 
Strategy.OAuth2Strategy.parseErrorResponse 
(/app/node_modules/passport-oauth2/lib/strategy.js:329:12) at 
Strategy.OAuth2Strategy._createOAuthError 
(/app/node_modules/passport-oauth2/lib/strategy.js:376:16) at 
/app/node_modules/passport-oauth2/lib/strategy.js:166:45 at 
/app/node_modules/oauth/lib/oauth2.js:191:18 at passBackControl 
(/app/node_modules/oauth/lib/oauth2.js:132:9) at 
IncomingMessage.<anonymous> (/app/node_modules/oauth/lib/oauth2.js:157:7) 
at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at 
endReadableNT (_stream_readable.js:1055:12) at _combinedTickCallback 
(internal/process/next_tick.js:138:11)

someone please help resolving this issue i have tried almost everything suggested in many links like

https://github.com/jaredhanson/passport-google-oauth/issues/82 Google Oauth giving code redeemed error but couldnt get success so far.

ghost commented 6 years ago

Try changing the code on the google site, maybe the problem is not in the passport.js.