Created
January 7, 2019 14:29
-
-
Save saltukalakus/b8f2fe279c26600b6f2f9ac93af662e3 to your computer and use it in GitHub Desktop.
Fetch User Profile Script Linkedin social old API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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