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
825 stars 153 forks source link

InternalOAuthError: failed to fetch user profile #24

Open AaronNGray opened 7 years ago

AaronNGray commented 7 years ago

Using both https://github.com/mjhea0/passport-examples and https://github.com/barberboy/passport-google-oauth2-example I am getting the following error :-

InternalOAuthError: failed to fetch user profile at C:\Users\aaron\Tests\JavaScript\Facebook\passport-examples\node_modules\passport-google-oauth2\lib\oauth2.js:92:28 at passBackControl (C:\Users\aaron\Tests\JavaScript\Facebook\passport-examples\node_modules\oauth\lib\oauth2.js:132:9) at IncomingMessage. (C:\Users\aaron\Tests\JavaScript\Facebook\passport-examples\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)

edahlseng commented 7 years ago

Did you set the "profile" scope in the strategy options? If you don't want the full user profile, you can alternatively set options.skipUserProfile to true to prevent this error.

hiepnm commented 6 years ago

+1 the same error. I enabled Google+ API too.

hiepnm commented 6 years ago

I got:

InternalOAuthError: failed to fetch user profile at /home/longnv/workspace/sm1/node_modules/passport-google-oauth2/lib/oauth2.js:92:28 at passBackControl (/home/longnv/workspace/sm1/node_modules/oauth/lib/oauth2.js:132:9) at IncomingMessage. (/home/longnv/workspace/sm1/node_modules/oauth/lib/oauth2.js:157:7) at IncomingMessage.emit (events.js:185:15) at endReadableNT (_stream_readable.js:1101:12) at process._tickCallback (internal/process/next_tick.js:114:19)

mergoc commented 5 years ago

did anyone ever figure out how to fix this?

teebu commented 4 years ago

using these scopes fixed my error:

scope: ['https://www.googleapis.com/auth/plus.login',
            'https://www.googleapis.com/auth/userinfo.email']
benjaminv commented 2 years ago

using these scopes fixed my error:

scope: ['https://www.googleapis.com/auth/plus.login',
            'https://www.googleapis.com/auth/userinfo.email']

I am new to this, where to implement this please?

Ashik155 commented 2 years ago

I have the same things going on

zulfikar4568 commented 2 years ago

I have same issue

image
sorasful commented 1 year ago

Hi @zulfikar4568 , by any chance did you manage to find a solution for this problem ?

sorasful commented 1 year ago

It seems that updating node version fixed the issue.

TheCreaToR-01 commented 1 year ago

using this userProfileURL: "https://www.googleapis.com/oauth2/v3/userinfo" solved my problem as google plus api is now deprecated

vishakhasingh4 commented 1 year ago

It seems that updating node version fixed the issue.

Hey, could you please explain exactly to which version we have to update? I am seeing the same error.

vishakhasingh4 commented 1 year ago

Hey, did anyone find the solution to this problem? Above things not working for me. I am using passport-google-oauth20 - version 2

chunkydonut21 commented 1 year ago

It seems that updating node version fixed the issue.

Thanks, man! It worked.

AshisheKumar commented 1 year ago

If anyone got the answer of the problem, please help...

AaronNGray commented 1 year ago

Have you tried the two solutions in this thread ?

On Wed, 9 Aug 2023 at 14:30, Ashish Kumar @.***> wrote:

If anyone got the answer of the problem, please help...

— Reply to this email directly, view it on GitHub https://github.com/jaredhanson/passport-google-oauth2/issues/24#issuecomment-1671332565, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAU4E6OWRK5S57IZ7LIQDDXUOGITANCNFSM4DGTUVLQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Aaron Gray - @@.***

Independent Open Source Software Engineer, Computer Language Researcher, Information Theorist, and Computer Scientist.

minhhn2910 commented 1 year ago

I also faced this problem today. For my case: cleaned node_modules, install node 18.17 LTS and reinstall all packages solved it.

AshisheKumar commented 1 year ago

Thanks for your support, I have mistakenly done a typo error 😅 .

On Wed, Aug 9, 2023, 9:34 PM minhhn2910 @.***> wrote:

I also faced this problem today. For my case: cleaned node_modules, install node 18.17 LTS and reinstall all packages solved it.

— Reply to this email directly, view it on GitHub https://github.com/jaredhanson/passport-google-oauth2/issues/24#issuecomment-1671718157, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7WA2YQGGTYAWMN6MQEMAVDXUOYJFANCNFSM4DGTUVLQ . You are receiving this because you commented.Message ID: @.***>

mukeshsinghmanral commented 2 months ago

add "openid" in scope, it will work

passport.use(new LinkedinStrategy({ clientID: process.env.LINKEDIN_CLIENT_ID, clientSecret: process.env.LINKEDIN_CLIENT_SECRET, callbackURL: "http://localhost:3000/auth/linkedin/callback", scope: ['email','profile','openid'],

},

AshisheKumar commented 2 months ago

add "openid" in scope, it will work

passport.use(new LinkedinStrategy({ clientID: process.env.LINKEDIN_CLIENT_ID, clientSecret: process.env.LINKEDIN_CLIENT_SECRET, callbackURL: "http://localhost:3000/auth/linkedin/callback", scope: ['email','profile','openid'],

},

Thanks, it Worked...