2011-08-26 73 views
2

我使用設計& Omniauth我的軌道3.0.7應用程序,我已經建立了一個有效的Twitter和Facebook登錄。我剛剛得到了谷歌企業應用套件登錄通過與以下行omniauth在config/initializers/omniauth.rb工作:Rails谷歌登錄omniauth

require 'openid/store/filesystem' 
use OmniAuth::Strategies::GoogleApps, OpenID::Store::Filesystem.new('/tmp') 

provider :openid, OpenID::Store::Filesystem.new('./tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id' 

但是這會導致與谷歌Apps的登錄。我如何才能讓用戶使用其標準Google帳戶登錄,而不是Google Apps(適用於企業)?這甚至是由Omniauth支持的嗎?

回答

0

我已將此作爲gem實施。如果你有興趣,你可以使用寶石本身或探索它的源代碼。這很簡單。

這是the engine file它配置設計。爲了支持你的代碼標準谷歌帳戶,你需要指定:domain選項,指出here

config.omniauth :google_apps, OpenID::Store::Filesystem.new('/tmp'), :domain => 'gmail.com' 
3

以前的答案可能不會在omniauth> 1.0工作。 看起來目前的做法是爲每個要使用的策略添加寶石。你可以在這裏找到的策略列表:

https://github.com/intridea/omniauth/wiki/List-of-Strategies

一個問題我遇到的是,新谷歌API返回的回調URL,它是太長的WEBrick。這可以通過運行薄或雜種的開發工作。