Skip to content

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

@jitendrakumar025

Description

@jitendrakumar025

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 ,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions