I try to get OAuth and Devise to work together, but I get Controller::RoutingError (No route matches "/users/auth/facebook/callback"): when trying to log in via Facebook.
Oddly enough, the problem does not occur with Google Apps. (same callback route).
Any ideas?
callback_controller:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def facebook # You need to implement the method below in your model @user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user) if @user.persisted? flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook" sign_in_and_redirect @user, :event => :authentication else session["devise.facebook_data"] = env["omniauth.auth"] redirect_to new_user_registration_url end end def google_apps @user = User.find_for_google_apps_oauth(env["omniauth.auth"], current_user) if @user.persisted? flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google Apps" sign_in_and_redirect @user, :event => :authentication else session["devise.google_apps_data"] = env["omniauth.auth"] redirect_to new_user_registration_url end end def passthru render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false end end
routes.rb:
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' end
Why :provider => "facebook" raises a RoutingError but not :provider => "google_apps" ?
source share