Skip to content

Commit

Permalink
Added required parameter type=web_server to authorization and token r…
Browse files Browse the repository at this point in the history
…equest
  • Loading branch information
enzy committed Jan 20, 2014
1 parent e86ebd7 commit 002c2d5
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions lib/passport-37signals/strategy.js
Expand Up @@ -45,7 +45,7 @@ function Strategy(options, verify) {
// http://groups.google.com/group/37signals-api/browse_thread/thread/86b0da52134c1b7e
options.authorizationURL = options.authorizationURL || 'https://launchpad.37signals.com/authorization/new';
options.tokenURL = options.tokenURL || 'https://launchpad.37signals.com/authorization/token';

OAuth2Strategy.call(this, options, verify);
this.name = '37signals';
}
Expand Down Expand Up @@ -73,27 +73,54 @@ util.inherits(Strategy, OAuth2Strategy);
Strategy.prototype.userProfile = function(accessToken, done) {
this._oauth2.get('https://launchpad.37signals.com/authorization.json', accessToken, function (err, body, res) {
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }

try {
var json = JSON.parse(body);

var profile = { provider: '37signals' };
profile.id = json.identity.id;
profile.displayName = json.identity.first_name + ' ' + json.identity.last_name;
profile.name = { familyName: json.identity.last_name,
givenName: json.identity.first_name };
profile.emails = [{ value: json.identity.email_address }];

profile._raw = body;
profile._json = json;

done(null, profile);
} catch(e) {
done(e);
}
});
}

/**
* Return extra parameters to be included in the authorization request.
*
* Adds type=web_server to params
*
* @param {Object} options
* @return {Object} params
*/
Strategy.prototype.authorizationParams = function(options) {
return {
type: 'web_server'
};
};

/**
* Return extra parameters to be included in the token request.
*
* Adds type=web_server to params
*
* @return {Object} params
*/
Strategy.prototype.tokenParams = function() {
return {
type: 'web_server'
};
};


/**
* Expose `Strategy`.
Expand Down

0 comments on commit 002c2d5

Please sign in to comment.