问题
I've looked through the documentation and I can't figure out the specific line I'm meant to use to get devise + omniauth + google working together nicely.
This strategy file suggests there's an easy way of doing it but I can't find an example.
https://github.com/intridea/omniauth/blob/master/oa-oauth/lib/omniauth/strategies/google.rb
At the moment I'm using the line below in the devise.rb initializer file.
config.omniauth :google, GOOGLE_APP_ID, GOOGLE_SECRET_KEY
but I'm pretty sure it's incomplete.
Also, I'm struggling to find where I should sign up for the google app id and secret key.
Thanks in advance. Graeme
回答1:
Google is an openid implementation. Add the following in your initial file
provider :openid, OpenID::Store::Filesystem.new('./tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
回答2:
The line I used in the end was ...
config.omniauth :google, GOOGLE_APP_ID, GOOGLE_SECRET, :scope => "http://www.google.com/m8/feeds http://picasaweb.google.com/data/"
Turns out I was missing the scope I needed to access Picasa, which was what was causing me problems.
回答3:
You may want to look at https://github.com/holden/devise-omniauth-example. In particular, look at the methods defined in user.rb, the user_token model they use, the devise views, and devise.rb. The last one in particular shows how you can configure devise/omniauth to work with google via openid: config.omniauth :google_apps, OpenID::Store::Filesystem.new('/tmp'), :domain => 'gmail.com'
Hope it helps :)
回答4:
I added the following lines to omniauth.rb and it worked like a charm:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :openid, nil, :name => 'google', :identifier =>'https://www.google.com/accounts/o8/id'
end
来源:https://stackoverflow.com/questions/5017901/whats-the-correct-configuration-line-to-get-devise-omniauth-and-google-working