diff --git a/lib/oauth2.js b/lib/oauth2.js index e4acb5e7..402f3ddc 100644 --- a/lib/oauth2.js +++ b/lib/oauth2.js @@ -27,7 +27,6 @@ Strategy.prototype.userProfile = function(accessToken, done) { this._oauth2.get(this.profileUrl, accessToken, function (err, body, res) { if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); } - try { var json = JSON.parse(body); @@ -41,8 +40,11 @@ Strategy.prototype.userProfile = function(accessToken, done) { }; profile.emails = [{ value: json.emailAddress }]; profile.photos = []; - if (json.pictureUrl) { - profile.photos.push(json.pictureUrl); + if (json.pictureUrls && json.pictureUrls.values) { + _.each(json.pictureUrls.values, function(pictureUrl){ + profile.photos.push(pictureUrl); + }) + } profile._raw = body; profile._json = json; @@ -65,6 +67,7 @@ Strategy.prototype._convertScopeToUserProfileFields = function(scope, profileFie 'first-name', 'last-name', 'picture-url', + 'picture-urls::(original)', 'formatted-name', 'maiden-name', 'phonetic-first-name',