Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saltukalakus/b8f2fe279c26600b6f2f9ac93af662e3 to your computer and use it in GitHub Desktop.
Save saltukalakus/b8f2fe279c26600b6f2f9ac93af662e3 to your computer and use it in GitHub Desktop.
Fetch User Profile Script Linkedin social old API
function(accessToken, ctx, cb) {
// call oauth2 APIwith the accesstoken and create the profile
request.get('https://api.linkedin.com/v1/people/~', {
headers: {
'Connection': 'Keep-Alive',
'Authorization': 'Bearer ' + accessToken,
'x-li-format': 'json'
},
}, function(e, r, b) {
if (e) return cb(e);
if (r.statusCode !== 200) return cb(new Error('StatusCode: ' + r.statusCode));
var profile = JSON.parse(b);
profile.user_id = profile.id;
profile.name = profile.firstName + ' ' + profile.lastName
cb(null, profile);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment