jaredhanson / passport-google-oauth

Google authentication strategies for Passport and Node.js.
https://www.passportjs.org/packages/passport-google-oauth/?utm_source=github&utm_medium=referral&utm_campaign=passport-google-oauth&utm_content=about
MIT License
776 stars 327 forks source link

Error without any desctiption #122

Open tkhatibi opened 7 years ago

tkhatibi commented 7 years ago

I get bellow error after redirect to my callback URL

Error
   at /media/tooraj/0AD25B25D25B1473/Users/2raj/Documents/Programming/node/- tickman/tickman-fullstack/node_modules/passport-google-oauth20/lib/strategy.js:95:21
   at passBackControl (/media/tooraj/0AD25B25D25B1473/Users/2raj/Documents/Programming/node/- tickman/tickman-fullstack/node_modules/oauth/lib/oauth2.js:132:9)
   at IncomingMessage.<anonymous> (/media/tooraj/0AD25B25D25B1473/Users/2raj/Documents/Programming/node/- tickman/tickman-fullstack/node_modules/oauth/lib/oauth2.js:157:7)
   at emitNone (events.js:91:20)
   at IncomingMessage.emit (events.js:185:7)
   at endReadableNT (_stream_readable.js:974:12)
   at _combinedTickCallback (internal/process/next_tick.js:74:11)
   at process._tickCallback (internal/process/next_tick.js:98:9)
LuukMoret commented 7 years ago

I also had this problem and the solution was to enable the Google+ API in the Google Developers Console

AaronNGray commented 7 years ago

I am getting the same thing and also on passport-google-oauth2 https://github.com/jaredhanson/passport-google-oauth2/issues/24

The Error shows up as InternalOAuthError: failed to fetch user profile on v6.10.2 LTS but jus as Error on v7.8.0 Current.

AaronNGray commented 7 years ago

It looks like the behaviour of the Google API has changed maybe due to authentification security changes .

bvodola commented 6 years ago

I'm using

"passport": "^0.4.0",
"passport-google-oauth20": "^1.0.0"

I followed @LuukMoret's suggestion but still wasn't able to make it work. So, in addition to adding the Google + API in the developer console, I added the following scope to the passport.authenticate scope array:

https://www.googleapis.com/auth/plus.login

Like this:

router.get('/google', 
  passport.authenticate('google', { scope: [
    'https://www.googleapis.com/auth/calendar',
    'https://www.googleapis.com/auth/plus.login'
]}));

And then it worked! =D