Reputation: 13055
I have got
gem 'omniauth-google_oauth2'
in my Gemfile. Did bundle install after that as well. It errors out saying,
ruby-1.9.3-p0/gems/omniauth-1.0.2/lib/omniauth/builder.rb:33:in `rescue in provider': Could not find matching strategy for :google_oauth2. You may need to install an additional gem (such as omniauth-google_oauth2). (LoadError)
What am I missing? Any ideas please.
Upvotes: 7
Views: 4292
Reputation: 5382
Using Ben W's solution made the server start-able but screws up how I was doing routes. I used this in config/initializers/omniauth.rb
:google_oauth2, "[KEY]", "[SECRET]"
My google auth path is then /auth/google_oauth2
Upvotes: 0
Reputation: 4064
The problem is caused by how OmniAuth camelizes the provider names:
OmniAuth::Utils.camelize(:google_oauth2.to_s)
=> GoogleOAuth2
However the provider is actually GoogleOauth2
- fully qualified - OmniAuth::Strategies::GoogleOauth2
So the solution is to use the fully qualified class:
OmniAuth::Strategies::GoogleOauth2
Rails.application.config.middleware.use OmniAuth::Builder do
provider OmniAuth::Strategies::GoogleOauth2, ENV["KEY"], ENV["SECRET"]
end
Upvotes: 8
Reputation: 325
Use
gem 'omniauth-google-oauth2'
Change the last underscore to a hyphen.
Upvotes: 11