Skip to content

Instantly share code, notes, and snippets.

@coybit
Created April 13, 2014 11:23
Show Gist options
  • Select an option

  • Save coybit/10579835 to your computer and use it in GitHub Desktop.

Select an option

Save coybit/10579835 to your computer and use it in GitHub Desktop.
Everyauth - Fetching user's email address when authenticating with Linkedin
everyauth.linkedin
.consumerKey(LINKEDIN_CONSUMER_KEY)
.consumerSecret(LINKEDIN_CONSUMER_SECRET)
.fetchOAuthUser(function (accessToken, accessTokenSecret, params) { // This method is override because we need to get extra info from user profile
var promise = this.Promise();
this.oauth.get(this.apiHost() + '/people/~:(id,first-name,last-name,emailAddress,headline,location:(name,country:(code)),industry,num-connections,num-connections-capped,summary,specialties,proposal-comments,associations,honors,interests,positions,publications,patents,languages,skills,certifications,educations,three-current-positions,three-past-positions,num-recommenders,recommendations-received,phone-numbers,im-accounts,twitter-accounts,date-of-birth,main-address,member-url-resources,picture-url,site-standard-profile-request:(url),api-standard-profile-request:(url,headers),public-profile-url)', accessToken, accessTokenSecret, function (err, data, res) {
if (err) {
err.extra = {data: data, res: res}
return promise.fail(err);
}
var oauthUser = JSON.parse(data);
promise.fulfill(oauthUser);
});
return promise;
})
.findOrCreateUser( function (session, accessToken, accessTokenSecret, linkedinUserMetadata) {
// Do what you want
})
.redirectPath('/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment