I'm using Devise & Omniauth on my rails 3.0.7 app, and I've already set up a functioning twitter and facebook logins. I just got Google Apps login working through omniauth with the following lines in config/initializers/omniauth.rb
:
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'
But this leads to a login with Google Apps. How do I just allow users to log in with their standard google accounts, not Google Apps (which is for corporates)? Is that even supported by O开发者_C百科mniauth?
The previous answer may not work in omniauth > 1.0. It looks like the current way to do this is to include the gem for every strategy you are going to use. You can find a list of strategies here:
https://github.com/intridea/omniauth/wiki/List-of-Strategies
One issue I ran into is that the new google api returns a callback url that is too long for webrick. This can be worked around by running dev in thin or mongrel.
I've implemented this as a gem. If you're interested you can use the gem itself or explore its source code. It's pretty simple.
This is the engine file which configures devise. To support standard google accounts in your code you need to specify the :domain
option as pointed out here
config.omniauth :google_apps, OpenID::Store::Filesystem.new('/tmp'), :domain => 'gmail.com'
精彩评论