passport-google-oauth2 icon indicating copy to clipboard operation
passport-google-oauth2 copied to clipboard

InternalOAuthError

Open Kamaraju333 opened this issue 8 years ago • 11 comments

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)

Kamaraju333 avatar Oct 07 '16 21:10 Kamaraju333

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

lukedesu avatar Aug 18 '17 16:08 lukedesu

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

TingAlex avatar Mar 21 '18 07:03 TingAlex

Same issue happening again...

RedTailBullet avatar Oct 19 '18 11:10 RedTailBullet

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.

lukedesu avatar Oct 24 '18 03:10 lukedesu

@senseluo That happens on my side as well.

RedTailBullet avatar Oct 24 '18 03:10 RedTailBullet

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 avatar Nov 01 '18 17:11 gyszalai

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

gyszalai avatar Nov 03 '18 12:11 gyszalai

I have the same issue, Who could help me?

spursy avatar Apr 28 '19 09:04 spursy

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...

TingAlex avatar Apr 29 '19 04:04 TingAlex

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

ThomasLai1991 avatar May 23 '20 07:05 ThomasLai1991

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

matinzd avatar Jan 18 '21 13:01 matinzd