5

My current /config/initializers/omniauth.rb file contains:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
end

When I login via Google by going to /auth/google, Google reports:

DOMAIN is asking for some information from your Google Account EMAIL - Email address: NAME (EMAIL)

My application doesn't need the user's email and so I'd like to remove this barrier to entry. Is there anyway to remove this requirement. For Facebook, I've found I can add the "scope" property of options, for example:

provider :facebook, 'APP_ID', 'APP_SECRET', {:scope => ''}
Shlomo Zalman Heigh
  • 3,968
  • 8
  • 41
  • 71
weotch
  • 5,788
  • 6
  • 35
  • 42
  • 1
    I think the trick is going to be customize the Attribute Exchange properties of the OpenId request, but I'm not sure how to do that. It looks like openid.ax.required and openid.ax.type.email may be relevant... – weotch Feb 13 '11 at 20:39
  • 1
    Is there an Omniauth IRC channel this can be asked on? I also need the answer. – Shlomo Zalman Heigh Feb 15 '11 at 23:16

1 Answers1

3

Based on a quick review of the source for the OpenID strategy (which Google Aps auth inherits from), you can pass in options specifying which attributes are optional vs. required for an Attributes Exchange (AX) auth.

See source code here for options: https://github.com/intridea/omniauth/blob/master/oa-openid/lib/omniauth/strategies/open_id.rb

Based on that, I think you could change the options like so to remove email as a required attribute:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id', :required => [], :optional => []
end

Good luck. I didn't test this, just reading the source.

Winfield
  • 18,985
  • 3
  • 52
  • 65