[英]How do I fetch the access token for a user using the Twitter gem and the Omniauth gem when the users is already logged in?
[英]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.