Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does anyone know of a node.js linkedin API example? [closed]

I'd like to do some LinkedIn API coding using node.js. Does anyone know of an example node.js application that implements the LinkedIn oauth?

thanks

like image 507
Simon Wentley Avatar asked Feb 03 '23 03:02

Simon Wentley


1 Answers

I've been using node-linkedin, very easy to setup, and you can do everything with it...It also looks a lot more promising than the answer with 5 votes.

Quick and easy setup example:

var Linkedin = require('node-linkedin')('app-id', 'secret'); // Get app-id + secret from your LinkedIn developer account

Initialise a linkedin class with a token, e.g an oauth2 token you received from your front-end. this.token = the token that was parsed to my api from the frontend.

var linkedin = Linkedin.init(this.token); // this.token = client token.

Here is a promised linkedin call that I'm using:

return new Promise( (fullfil, reject) => {
      linkedin.people.me( (err, user) => {
        console.log (user, "All user data attached to this.token");
        let resp = {response: user, error: null};
        if (err) resp = {response: null, error: err};
        else {
          this.email = user.emailAddress;
          this.id = user.id;
        }

        fullfil(resp)
      });
});

Without the promise it'd look like this:

linkedin.people.me( (err, user) => { console.log (user); });
like image 68
James111 Avatar answered Feb 12 '23 02:02

James111