passport-renren
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -8,3 +8,2 @@ /** | ||
/** | ||
@@ -54,3 +53,3 @@ * `Strategy` constructor. | ||
options.authorizationURL = options.authorizationURL || 'https://graph.renren.com/oauth/authorize'; | ||
options.tokenURL = options.tokenURL || 'https://login.renren.com/mlogin/auth/token'; | ||
options.tokenURL = options.tokenURL || 'https://graph.renren.com/oauth/token'; | ||
options.scopeSeparator = options.scopeSeparator || ','; | ||
@@ -65,3 +64,3 @@ options.customHeaders = options.customHeaders || {}; | ||
this.name = 'renren'; | ||
this._userProfileURL = options.userProfileURL || 'https://api.renren.com/v2/user'; | ||
this._userProfileURL = options.userProfileURL || 'https://api.renren.com/restserver.do'; | ||
} | ||
@@ -81,8 +80,11 @@ | ||
* - `provider` always set to `renren` | ||
* - `id` the user's Renren ID | ||
* - `username` the user's Renren username | ||
* - `uid` the user's Renren ID | ||
* - `tinyurl` the user's Renren profile image | ||
* - `displayName` the user's full name | ||
* - `profileUrl` the URL of the profile for the user on GitHub | ||
* - `emails` the user's email addresses | ||
* - `vip` the URL of the profile for the user on GitHub | ||
* - `name` the user's name | ||
* - `star` whether user is a Renren star user | ||
* | ||
* reference http://wiki.dev.renren.com/wiki/API | ||
* | ||
* @param {String} accessToken | ||
@@ -93,18 +95,22 @@ * @param {Function} done | ||
Strategy.prototype.userProfile = function(accessToken, done) { | ||
this._oauth2.get(this._userProfileURL, accessToken, function (err, body, res) { | ||
this._oauth2._request('POST', this._userProfileURL + '?access_token=' + accessToken + '&format=json&method=users.getInfo', | ||
{'content-type': 'application/x-www-form-urlencoded'} , accessToken, '', function (err, body, res) { | ||
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); } | ||
try { | ||
var json = JSON.parse(body); | ||
var json = JSON.parse(body)[0]; | ||
var profile = { provider: 'renren' }; | ||
profile.id = json.id; | ||
profile.id = json.uid; | ||
profile.tinyurl = json.tinyurl; | ||
profile.displayName = json.name; | ||
profile.username = json.login; | ||
profile.profileUrl = json.html_url; | ||
profile.emails = [{ value: json.email }]; | ||
profile.vip = json.vip; | ||
profile.name = json.name; | ||
profile.star = json.star; | ||
profile.headurl = json.headurl; | ||
profile.zidou = json.zidou; | ||
profile._raw = body; | ||
profile._json = json; | ||
done(null, profile); | ||
@@ -111,0 +117,0 @@ } catch(e) { |
{ | ||
"name": "passport-renren", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "GitHub authentication strategy for Passport.", | ||
@@ -5,0 +5,0 @@ "keywords": ["passport", "renren", "auth", "authn", "authentication", "identity"], |
8824
122