Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support openid.realm parameter #42

Merged
merged 1 commit into from Mar 4, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -44,7 +44,7 @@ function Strategy(options, verify) {
options = options || {};
options.authorizationURL = options.authorizationURL || 'https://accounts.google.com/o/oauth2/auth';
options.tokenURL = options.tokenURL || 'https://accounts.google.com/o/oauth2/token';

OAuth2Strategy.call(this, options, verify);
this.name = 'google';
}
@@ -72,20 +72,20 @@ util.inherits(Strategy, OAuth2Strategy);
Strategy.prototype.userProfile = function(accessToken, done) {
this._oauth2.get('https://www.googleapis.com/oauth2/v1/userinfo', 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: 'google' };
profile.id = json.id;
profile.displayName = json.name;
profile.name = { familyName: json.family_name,
givenName: json.given_name };
profile.emails = [{ value: json.email }];

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

done(null, profile);
} catch(e) {
done(e);
@@ -134,6 +134,11 @@ Strategy.prototype.authorizationParams = function(options) {
// https://developers.google.com/accounts/docs/OAuth_ref
params['hd'] = options.hostedDomain || options.hd;
}
if (options.openIdRealm) {
// This parameter is needed when migrating users from Google's OpenID 2.0 to OAuth 2.0
// https://developers.google.com/accounts/docs/OpenID?hl=ja#adjust-uri
params['openid.realm'] = options.openIdRealm;
}
return params;
}

ProTip! Use n and p to navigate between commits in a pull request.