Skip to content

Commit

Permalink
Merge c0f3eb9 into 338a4cf
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Warbo committed Jun 20, 2015
2 parents 338a4cf + c0f3eb9 commit d6795cb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/strategy.js
Expand Up @@ -49,11 +49,13 @@ function Strategy(options, verify) {
options.accessTokenURL = options.accessTokenURL || 'https://api.twitter.com/oauth/access_token';
options.userAuthorizationURL = options.userAuthorizationURL || 'https://api.twitter.com/oauth/authenticate';
options.sessionKey = options.sessionKey || 'oauth:twitter';
options.email = options.email || false;

OAuthStrategy.call(this, options, verify);
this.name = 'twitter';
this._userProfileURL = options.userProfileURL || 'https://api.twitter.com/1.1/users/show.json';
this._skipExtendedUserProfile = (options.skipExtendedUserProfile !== undefined) ? options.skipExtendedUserProfile : false;
this._email = options.email;
}

/**
Expand Down Expand Up @@ -107,8 +109,14 @@ Strategy.prototype.authenticate = function(req, options) {
Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
if (!this._skipExtendedUserProfile) {
var json;

this._oauth.get(this._userProfileURL + '?user_id=' + params.user_id, token, tokenSecret, function (err, body, res) {
var userProfileURL;
if (this._email) {
userProfileURL = 'https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true';
} else {
userProfileURL = this._userProfileURL + '?user_id=' + params.user_id;
}

this._oauth.get(userProfileURL, token, tokenSecret, function (err, body, res) {
if (err) {
if (err.data) {
try {
Expand Down

0 comments on commit d6795cb

Please sign in to comment.