Integrating Omniauth/Facebook: Auth route not set
Hi,
I've followed the tutorial on how to integrate Openauth, but the authentication route simply doesn't exist - Omniauth doesn't intercept it, it just returns a 404 / No route matches error.
- I've used Devise from Github, master branch, like this (in my Gemfile):
gem 'devise', :git => "git://github.com/plataformatec/devise.git"
- Also, I've used Omniauth 0.2.0 beta5:
gem 'oa-oauth', '0.2.0.beta5', :require => "omniauth/oauth"
- In my config/initializers/devise.rb, Omniauth is initialized:
config.omniauth :facebook, "APP ID", "APP SECRET"
- In my user model, I've added
devise [...], :omniauthable
- In my routes.rb I've added the callback routing, and I've implemented the callback controller, but that shouldn't even matter, because the problem is not with devise, it's with Omniauth. It simply doesn't generate the auth route!
- When I run "rake middleware" it does show:
use OmniAuth::Strategies::Facebook
- Yes, I've restarted the server, multiple times.
- I'm trying to get this to run on my Webrick development server, but I've also tried on the production Apache and it doesn't work either.
The routes I've tried are:
http://localhost:3000/auth/facebook
http://localhost:3000/users/auth/facebook
They both return 404 errors.
Unfortunately I've never worked with Rack applications and they're kind of a mystery to me, so I'm not sure what Omniauth is or isn't supposed to do and how to debug it.
Anybody who might know what the issue is? It seems your tutorial isn't clear enough, since I've read it 100 times and followed the steps but it doesn't work. Actually, I've been working on this one issue for 10 hours now, taking apart every single file in the Devise and Omniauth gems, but I simply can't find the issue... Any help or suggestions would be MUCH appreciated!
I can't see the issue also. Can you post also the result of rake routes?
rake routes shows the callback route, of course:
user_omniauth_callback (/:locale)/auth/:action/callback(.:format) {:action=>/facebook/, :controller=>"omniauth_callbacks"}
...but the auth route doesn't show up at all.
Sorry I accidentally closed the issue. Pls reopen.
Something is wrong with your route... It doesn't have the /users at the beginning... probably a conflict with the locale... i will investigate.
One last thing, how are you calling devise_for in your routes? Which parameters? It is inside a scope?
Yes, like this:
scope "(:locale)" do
devise_for :users,
:controllers => {
:sessions => 'internal/sessions',
:registrations => 'internal/registrations',
:confirmations => 'devise/confirmations',
:passwords => 'internal/passwords',
:omniauth_callbacks => 'omniauth_callbacks'
},
:path => '',
:path_names => {:sign_in => 'sign_in', :sign_out => 'sign_out', :sign_up => 'sign_up'}
end
I have fixed on Devise master. Could you please try it? Tks!
Umm..thank you, but actually the callback route wasn't my problem. It was the "/facebook/auth" which didn't work, and which doesn't even come from devise, but from Omniauth as I understand.
It still doesn't work.
rake routes result from master please?
user_omniauth_callback /auth/:action/callback(.:format) {:action=>/facebook/, :controller=>"omniauth_callbacks"}
The auth route doesn't show up.
Hrm, this is weird. Final test, please try on rails console: "puts Omniauth.config.path_prefix"
NameError: uninitialized constant Omniauth
Ugh, my bad! Please try: "::OmniAuth.config.path_prefix"
The result is: //auth
A-ha. That is the issue. One sec.
Please try again on master. :D
It works, finally! Thanks a lot man, you saved my day.
Today you, tomorrow me: http://www.reddit.com/r/AskReddit/comments/elal2/have_you_ever_picked_up_a_hitchhiker/c18z0z2
:D
Thanks, saved my day!