Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InternalOAuthError: failed to fetch user profile (new Community Management API of LinkedIn) #102

Open
jitendrakumar025 opened this issue Oct 15, 2023 · 9 comments · May be fixed by #103
Open

Comments

@jitendrakumar025
Copy link

jitendrakumar025 commented Oct 15, 2023

InternalOAuthError: failed to fetch user profile
at Strategy. (C:\VsCode\OfficeINK\OfficeInk-api\node_modules\passport-linkedin-oauth2\lib\oauth2.js:57:19)
at passBackControl (C:\VsCode\OfficeINK\OfficeInk-api\node_modules\oauth\lib\oauth2.js:132:9)
at IncomingMessage. (C:\VsCode\OfficeINK\OfficeInk-api\node_modules\oauth\lib\oauth2.js:157:7)
at IncomingMessage.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

I have been stuck in this error for 1 week, I googled about this error but couldn't get an updated solution according to new Community Management API of LinkedIn, Please help me @jamescgarrett .

The following is Passport linkedinStrategy configuration :

`require('dotenv').config();
const LinkedInStrategy = require("passport-linkedin-oauth2").Strategy;
const passport = require("passport");

passport.serializeUser((user, done) => {
done(null, user);
});

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

  },async (accessToken, refreshToken, done) => {
    try {
      const userInfo = await linkedin.getProfile(
        process.env.LINKEDIN_CLIENT_ID,
        process.env.LINKEDIN_CLIENT_SECRET,
        accessToken
      );
      console.log(userInfo)
      done(null, userInfo);
    } catch (err) {
      console.log(err)
      done(err, false);
    }
  }
)

);

passport.deserializeUser((user, done) => {
done(null, user);
});`

server running on localhost:5000,

Please help me, Its a lot to me.
Thanks ,

@ErcilioMarques
Copy link

ErcilioMarques commented Oct 18, 2023

facing same issue, seems like the new major change on linkedin API break everything. and their current doc its not clear

@herquiloidehele
Copy link

Having the same problem here

@angelhodar
Copy link

angelhodar commented Oct 25, 2023

@ErcilioMarques @herquiloidehele Do you guys have the problem just with the basic readme config? I dont understand why it fails because this library has been updated just a month ago to use the new OpenID API from linkedin.

Edit: Ok it seems that they havent updated it to npm so its still installing the old API... I have emailed @jamescgarrett about it so he will probably fix it soon. For now, you can just install it manually via npm:

npm install github:auth0/passport-linkedin-oauth2

And the code just works perfectly!!!

@jamescgarrett
Copy link
Contributor

Hey all, apologies for the issues you are running into. As you are aware LinkedIn has deprecated Sign In with LinkedIn and is now enforcing new apps to use Sign In with LinkedIn using OpenID Connect. We've made the necessary changes to this repo supporting this change, but have not yet published the changes to npm. We are working on getting newer versions published in npm, but for now you should be able to install the updates using
npm install github:auth0/passport-linkedin-oauth2
or
npm install github:auth0/passport-linkedin-oauth2#v3.0.0

@vilasshetkar
Copy link

Hi @jamescgarrett,
I've thoroughly investigated this issue and implemented a fix in the Community Management API Fix PR. I've tested the solution, and it resolves the issue. Kindly review and merge this PR at your earliest convenience to close the problem.

Thanks!

@GodoyMS
Copy link

GodoyMS commented Feb 13, 2024

Hi,
Adding a new field 'openid' on the scope array worked for me

new LinkedinStrategy({ clientID: config.OAUTH2_ID_CLIENT_LINKEDIN!, clientSecret: config.OAUTH2_SECRET_LINKEDIN!, callbackURL: http://localhost:5000/auth/linkedin/callback, scope: ['email', 'profile','openid'], }

@NabilSaikaly
Copy link

Hello @jamescgarrett 😄

Hope all is going well.

Will the newer versions be published to npm?

@pedroresende
Copy link

@jamescgarrett why not publish this to npm ?

@sakshiarora386
Copy link

plz do publish this to npm, to avoid these issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
10 participants