Reputation: 10885
I'm using 'omniauth-google-oauth2' for sign in with google and follow all instruction here carefully
https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview
but i have error above.
my routes
devise_for :users, :controllers => {
:omniauth_callbacks => "users/omniauth_callbacks"
}
devise.rb code
config.omniauth :google_oauth2, "863625299460- 420n6c7lvad91dfvko60uamtvtr6huhf.apps.googleusercontent.com", "dcvA2aZRZi27KCQjWTYP30pw", { access_type: "offline", approval_prompt: "" }
omniauth callback controller code
def google_oauth2
#@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)
binding.pry #control not coming here
end
i have error below after callback. see screenshot
https://github.com/zquestz/omniauth-google-oauth2/issues/52
Upvotes: 3
Views: 2400
Reputation: 442
It's very late but this answer might be useful for others
If you are using devise
for authentication then devise by default generates routes in the route file devise_for :users
and your omniouth_callback
route should be above the default devise
route so that it overwrites default devise route.
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks"}
devise_for :users
Upvotes: 0
Reputation: 3548
I had exactly the same problem you described. Make sure you require the omniauth-google-oauth2 gem in config/initializers/deviser.rb
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
require "omniauth-google-oauth2"
config.omniauth :google_oauth2, ENV["GOOGLE_KEY"], ENV["GOOGLE_SECRET"],
{ access_type: "offline", approval_prompt: "force" }
I've added the entire portion of my devise.rb file to provide context.
Upvotes: 0
Reputation: 776
This looks like a route issue. If you do "rake routes | grep auth" what do you see?
Upvotes: 1