[英]How do I NOT require user's email when using Rails Omniauth gem and Google OpenID
My current /config/initializers/omniauth.rb file contains: 我当前的/config/initializers/omniauth.rb文件包含:
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: 当我通过访问/ auth / google登录Google时,Google会报告:
DOMAIN is asking for some information from your Google Account EMAIL - Email address: NAME (EMAIL)
DOMAIN要求您提供来自Google帐户的一些信息EMAIL - 电子邮件地址: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:
对于Facebook,我发现我可以添加选项的“范围”属性,例如:
provider :facebook, 'APP_ID', 'APP_SECRET', {:scope => ''}
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. 基于对OpenID策略(Google Aps auth继承)的来源的快速回顾,您可以传入选项,指定哪些属性是可选的,而不是Attributes Exchange(AX)身份验证所需的属性。
See source code here for options: https://github.com/intridea/omniauth/blob/master/oa-openid/lib/omniauth/strategies/open_id.rb 有关选项,请参阅此处的源代码: 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.
我没有测试这个,只是阅读源代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.