2

I have problem with omniauth-google-oath2 gem.

My code:

devise.rb

config.omniauth :google_oauth2, 'app_id','secret'

omniauth_callbacks_controller.rb

def google_oauth2
   auth = env["omniauth.auth"]

   @user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user) 
   if @user.persisted?
     flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
     sign_in_and_redirect @user, :event => :authentication
   else
     session["devise.google_uid"] = request.env["omniauth.auth"]
     redirect_to new_user_registration_url
   end
end

I also provide method for find_for_google_oauth2 in my user.rb model. In my html.erb I wrote:

<%= link_to "With Google", user_omniauth_authorize_path(:google_oauth2) %>

And in the end I have this error: No route matches {:controller=>"omniauth_callbacks", :action=>"passthru", :provider=>:google_oauth2, :format=>nil} missing required keys: [:provider]

Where is my mistake? Thanks for any advance!

0

2 Answers 2

5

Check the user model for

devise :omniauthable, omniauth_providers: [:google_oauth2]

it's probably missing or wrong.

0

I solved my problem. It was stupid :) I just restarted my local rails server and everything working fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.