您可以使用name
選項。這應該與任何OmniAuth供應商合作:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, 'GOOGLE_CLIENT_ID', 'GOOGLE_CLIENT_SECRET', {
:name => 'google'
}
provider :google_oauth2, 'GOOGLE_CLIENT_ID', 'GOOGLE_CLIENT_SECRET', {
:name => 'google_full',
:scope => 'original_scope, extra_scope'
}
end
隨着omniauth - 谷歌 - 的oauth2不過,你可以採取另一種方法:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, 'GOOGLE_CLIENT_ID', 'GOOGLE_CLIENT_SECRET', {
:name => 'google'
}
provider :google_oauth2, 'GOOGLE_CLIENT_ID', 'GOOGLE_CLIENT_SECRET', {
:name => 'google_full',
:scope => 'extra_scope',
:prompt => 'consent',
:include_granted_scopes => 'true'
}
end
瞭解更多詳細信息退房Google's Incremental Authorization guide。
請注意,通過更改提供商的name
,OmniAuth URL將更改爲/auth/new_name
,然後request.env['omniauth.auth']['provider']
將返回new_name
。
您是否找到更好的解決方案? – Bazinga