LinkedIn Node
npm install linkedin-node-new
You can run the test by cloning this repo and running:
npm install
node test/test
For setting up:
var linkedInObj = require('linkedin-node-new');
var linkedIn = new linkedInObj({
id: 'MYCLIENTID',
secret: 'MYCLIENTSECRET',
scope: '', // optional, set the scope of your app
redirect_uri: 'http://localhost:9000/#!/oauth/linkedin'
});
var url = linkedIn.createURL();
After you have obtained the 'code' (either via your redirect or elsewhere):
var code = ''; // put the short-time auth code in here.
linkedIn.getAccessToken(code, function(err, access_token) {
console.log(err);
console.log(access_token);
});
If you have saved your access token in some sort of session or cookie data, you can skip the authorization request:
var linkedIn = new linkedInObj({
id: 'MYCLIENTID',
secret: 'MYCLIENTSECRET',
redirect_uri: 'http://localhost:9000/#!/oauth/linkedin',
access_token: 'MYACCESSTOKEN'
});
Once authorized, you can perform typical REST services (http://docs.linkedIn.com/api/ for reference):
// GET
linkedIn.get('/v1/people/~:(id,first-name,last-name,headline,positions,picture-url,email-address)', function(err, res) {
if(err) {
return console.log(err);
}
console.log(res);
console.log(res.positions.values[0]);
});
// POST
// PUT
// DELETE
Built in Ohio. www.typefoo.com