Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes to Foursquare code. Now supporting LinkedIn.
- Loading branch information
Showing
6 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var oauthModule = require('./oauth') | ||
, Promise = require('./promise') | ||
, OAuth = require('oauth').OAuth; | ||
|
||
var linkedin = module.exports = | ||
oauthModule.submodule('linkedin') | ||
.definit( function () { | ||
this.oauth = new OAuth( | ||
this.oauthHost() + this.requestTokenPath() | ||
, this.oauthHost() + this.accessTokenPath() | ||
, this.consumerKey() | ||
, this.consumerSecret() | ||
, '1.0', null, 'HMAC-SHA1', null | ||
, { | ||
Accept: '/' | ||
, Connection: 'close' | ||
, 'User-Agent': 'Node authentication' | ||
, 'x-li-format': 'json' // So we get JSON responses | ||
}); | ||
}) | ||
|
||
.apiHost('https://api.linkedin.com/v1') | ||
.oauthHost('https://api.linkedin.com') | ||
|
||
.requestTokenPath('/uas/oauth/requestToken') | ||
.authorizePath('/uas/oauth/authorize') | ||
.accessTokenPath('/uas/oauth/accessToken') | ||
|
||
.entryPath('/auth/linkedin') | ||
.callbackPath('/auth/linkedin/callback') | ||
|
||
.redirectToProviderAuth( function (res, token) { | ||
res.writeHead(303, { 'Location': 'https://www.linkedin.com' + this.authorizePath() + '?oauth_token=' + token }); | ||
res.end(); | ||
}) | ||
|
||
.fetchOAuthUser( function (accessToken, accessTokenSecret, params) { | ||
var promise = new Promise(); | ||
this.oauth.get(this.apiHost() + '/people/~:(id,first-name,last-name,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) { | ||
if (err) return promise.fail(err); | ||
var oauthUser = JSON.parse(data); | ||
console.log(oauthUser); | ||
promise.fulfill(oauthUser); | ||
}); | ||
return promise; | ||
}) | ||
.convertErr( function (data) { | ||
var errJson = JSON.parse(data.data) | ||
, errMsg = errJson.message; | ||
return new Error(errMsg); | ||
}); |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ oauthModule.submodule('twitter') | |
promise.fulfill(oauthUser); | ||
}); | ||
return promise; | ||
}) | ||
}); |