jaredhanson / passport-google-oauth2

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

InternalOAuthError #16

Open Kamaraju333 opened 8 years ago

Kamaraju333 commented 8 years ago

WHEN I TRYING TO LOGIN WITH GOOGLE OAUTH2 I SEE THIS ERROR

InternalOAuthError: Failed to obtain access token at Strategy.OAuth2Strategy._createOAuthError (/Users/kprat1/learning/passportexamples2/passport-examples/node_modules/passport-oauth2/lib/strategy.js:370:17) at /Users/kprat1/learning/passportexamples2/passport-examples/node_modules/passport-oauth2/lib/strategy.js:166:45 at /Users/kprat1/learning/passportexamples2/passport-examples/node_modules/oauth/lib/oauth2.js:177:18 at ClientRequest. (/Users/kprat1/learning/passportexamples2/passport-examples/node_modules/oauth/lib/oauth2.js:148:5) at emitOne (events.js:90:13) at ClientRequest.emit (events.js:182:7) at TLSSocket.socketErrorListener (_http_client.js:295:9) at emitOne (events.js:90:13) at TLSSocket.emit (events.js:182:7) at emitErrorNT (net.js:1250:8) at _combinedTickCallback (node.js:377:13) at process._tickCallback (node.js:401:11)

lukedesu commented 7 years ago

i got the same issue, how did you fix it?

TingAlex commented 6 years ago

I got the exactly same issue, so could you teach me how to fix it please? @Kamaraju333 @senseluo

RedTailBullet commented 5 years ago

Same issue happening again...

lukedesu commented 5 years ago

Seems i did nothing but push it to production environment and everything works well again. but in my local machine, this issue happening again and again.

RedTailBullet commented 5 years ago

@senseluo That happens on my side as well.

gyszalai commented 5 years ago

I had the same problem with getting the user profile. It seems that the userinfo URL has changed as Google shuts down google+

The default userinfo URL in passport-google-oauth2 is https://www.googleapis.com/plus/v1/people/me

But the official userinfo URL seems to be: https://www.googleapis.com/oauth2/v3/userinfo

You can read more about Google OpenID Connect at https://developers.google.com/identity/protocols/OpenIDConnect#discovery

gyszalai commented 5 years ago

If you run your application in a Docker container, make sure that your Docker default bridge is reconfigured as the default config is 172.x.x.x and in my case it conflicted with a google ip address 172.217.23.74

spursy commented 5 years ago

I have the same issue, Who could help me?

TingAlex commented 5 years ago

I have the same issue, Who could help me?

Have you tried use a global proxy? Only in case you are unfortunately located in China like me...

ThomasLai1991 commented 4 years ago

I have the same issue, Who could help me?

Have you tried use a global proxy? Only in case you are unfortunately located in China like me...

I have this issue as well, and I am in China, how to fix this then? Is it something to do with proxy or vpn? thank you

matinzd commented 3 years ago

I have the same issue when I run this inside docker container with Nginx reverse proxy configured.

authentication-ms | [Nest] 18   - 01/18/2021, 1:33:58 PM   [ExceptionsHandler] Failed to obtain access token +11011ms
authentication-ms | InternalOAuthError: Failed to obtain access token
authentication-ms |     at GoogleStrategy.OAuth2Strategy._createOAuthError (/usr/src/app/node_modules/passport-oauth2/lib/strategy.js:408:17)
authentication-ms |     at /usr/src/app/node_modules/passport-oauth2/lib/strategy.js:175:45
authentication-ms |     at /usr/src/app/node_modules/oauth/lib/oauth2.js:191:18
authentication-ms |     at ClientRequest.<anonymous> (/usr/src/app/node_modules/oauth/lib/oauth2.js:162:5)
authentication-ms |     at ClientRequest.emit (events.js:210:5)
authentication-ms |     at TLSSocket.socketErrorListener (_http_client.js:406:9)
authentication-ms |     at TLSSocket.emit (events.js:210:5)
authentication-ms |     at emitErrorNT (internal/streams/destroy.js:92:8)
authentication-ms |     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
authentication-ms |     at processTicksAndRejections (internal/process/task_queues.js:80:21