繁体   English   中英

使用Rails Omniauth gem和Google OpenID时,如何不要求用户发送电子邮件

[英]How do I NOT require user's email when using Rails Omniauth gem and Google OpenID

我当前的/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

当我通过访问/ auth / google登录Google时,Google会报告:

DOMAIN要求您提供来自Google帐户的一些信息EMAIL - 电子邮件地址:NAME(EMAIL)

我的应用程序不需要用户的电子邮件,因此我想删除此入门障碍。 无论如何都有删除此要求。 对于Facebook,我发现我可以添加选项的“范围”属性,例如:

provider :facebook, 'APP_ID', 'APP_SECRET', {:scope => ''}

基于对OpenID策略(Google Aps auth继承)的来源的快速回顾,您可以传入选项,指定哪些属性是可选的,而不是Attributes Exchange(AX)身份验证所需的属性。

有关选项,请参阅此处的源代码: https//github.com/intridea/omniauth/blob/master/oa-openid/lib/omniauth/strategies/open_id.rb

基于此,我认为您可以更改这样的选项以删除电子邮件作为必需属性:

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

祝好运。 我没有测试这个,只是阅读源代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM