linkedin-exchange-tokens
A simple function to exchange the short-lived OAuth2 token provided by the LinkedIn JSAPI to a long-lived OAuth token that can be used by the server to make REST api calls.
This mechanism is described in this linked-in documentation
This module also has a way to make REST API calls to linked in though that can be done using other modules as well.
Install
npm install linkedin-exchange-tokens
Usage
var exchangeTokens = require('linkedin-exchange-tokens');
var options = {
'public': 'Your Linked In API Key',
'secret': 'Your Linked In API Secret'
};
var oauth2Token = '<token from browser JSAPI: for example: IN.ENV.auth.oauth_token>';
exchangeTokens(options, oauth2Token, function (err, tokenInfo) {
tokenInfo.api('/v1/people/~/connections, {}, function (err, info) {
// boom!
});
});
You can also make REST calls with this API using OAuth1.0 tokens.
var exchangeTokens = require('linkedin-exchange-tokens');
var options = {
'public': 'Your Linked In API Key',
'secret': 'Your Linked In API Secret'
};
exchangeTokens.makeTokenInfo(options, tokenInfo)
.api('/v1/people/~/connections', {}, function (err, info) {
});
Environment variables
You can pass the linked in API key and secret via environment variables instead of via the options parameter.
- LIN_API_KEY -- set this to the public API key
- LIN_API_SECRET -- set this to the API secret