I solved my problem. It was stupid :) I just restarted my local rails server and everything working fine.
Google omniauth doesn't recognize path
-
12-10-2022 - |
Pregunta
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!
Solución 2
Otros consejos
Check the user model for
devise :omniauthable, omniauth_providers: [:google_oauth2]
it's probably missing or wrong.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow