Search code examples
javascriptmeteorlinkedin-apimeteor-accounts

How do I add LinkedIn login to Meteor?


I have tried both pauli:accounts-linkedin and jonperl:linkedin packages in combination with accounts-base & accounts-oauth. I tried it with and without accounts-ui. My Facebook login button is working seemlessly. The error I now get is:

Uncaught TypeError: Meteor.loginWithLinkedin is not a function

Once this works, I would also like to customize the permissions granted. If you have any hints on what could be wrong/what I could have forgotten, that'd be great. Otherwise, if you are aware of any example projects or docs, that would be nice, because I could not find any!


Solution

  • So the way I made it eventually work is with the pauli:accounts-linkedin package. Accounts-UI package doesn't work, so just build your own login button:

    in html:

    <button id="loginBtn">Login with LinkedIn</button>
    

    in javascript:

    Template.loginTemplate.events({
      'click #loginBtn':function(){
        Meteor.loginWithLinkedIn({
          requestPermissions: ['r_basicprofile','r_emailaddress']
          }, function(err){
            if(err){
              console.log('error with login is: ', err);
            }
        });
      }
    });
    

    the permissions are to be found on the developer page of linkedin. Last step now is to add the following document to the meteor_accounts_loginServiceConfiguration collection:

    { 
        "_id" : "J2LPm7ocGfzuiK9J2", 
        "service" : "linkedin", 
        "clientId" : [clientID from linkedin developer page], 
        "secret" : [secret from linkedin developer page]
    }