How to implement LinkedIn Login in ionic 3? why Linked In Login is not working?

Viewed 878

I am using this tutorial.

My code is:

linkedInSignup() {
console.log("linked in login....");

// check if there is an active session
this.linkedin.hasActiveSession().then((active) => {
  console.log('has active session?', active);
  if(active === false) {
    // login
    let scopes:any = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];
    this.linkedin.login(scopes, true)
      .then(() => console.log('Logged in!'))
      .catch(e => console.log('Error logging in', e));


    // get connections
    this.linkedin.getRequest('people/~')
      .then(res => console.log(res))
      .catch(e => console.log(e));

    // share something on profile
    const body = {
      comment: 'Hello world!',
      visibility: {
        code: 'anyone'
      }
    };

    this.linkedin.postRequest('~/shares', body)
      .then(res => console.log(res))
      .catch(e => console.log(e));
  }
});

}

Installed plugin:

$ ionic cordova plugin add cordova-plugin-linkedin --variable APP_ID=YOUR_APP_ID
$ npm install --save @ionic-native/linkedin

There is not getting any error, but even doesn't login with Linked In.

Can you please help me to solve this issue? Thanks.

1 Answers

I am trying to implement LinkedIn login as well in my application and was also facing the same issue. The login function never passed the success callback.

After doing a little search I came across this - https://github.com/zyra/cordova-plugin-linkedin#deprecation-notice

Looks like LinkedIn has stopped support for mobile SDK and have asked all the developers to move to OAuth 2.0

Ref - https://engineering.linkedin.com/blog/2018/12/developer-program-updates

Edit:

So the workaround that I used to serve my purpose of allowing users to signup with LinkedIn was that as I was using Node.js for my server-side work. I used passport.js with LinkedIn oAuth, and in the ionic app, I made use of the Ionic InApp Browser to show the user the LinkedIn signup page and register user from the app through LinkedIn.

This is the solution that I have currently tried, but looking for some better option if possible using any Cordova plugin. Will update the answer again if I find any.

Related