4

I am getting this error when i am using omniauth, rails 4.2.1. I have installed the omniauth gem & omniauth facebook.

routes.rb

get 'auth/:provider/callback', to: 'users#create'
get 'auth/failure', to: redirect('/')
get 'signout', to: 'users#destroy', as: 'signout'

initializers/omniauth.rb

OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, 'APP_KEY', 'APP_SEC_KEY'
end

I am finding this error

No route matches [GET] "/auth/facebook"

can anyone please help me out on this, I did lot researches and tried, but nothing seems to work.

Saravana
  • 115
  • 7
  • Have you tried this http://stackoverflow.com/questions/20690946/omniauth-error-no-route-matches-get-auth-facebook . Also check your facebook configuration is proper or not – Dipak Gupta Sep 01 '15 at 13:41
  • Have you restarted your server since installing the gem? Also run `rake routes` in your console and see what output it gives for facebook (search 'facebook') – miler350 Sep 01 '15 at 13:52
  • @Dipak I tried that stackoverflow, but it didn't worked in my case – Saravana Sep 01 '15 at 14:12
  • @miler350 It is working fine in my localhost, i.e, [http://localhost:3000/auth/facebook] , but in my development server it doesn't work. 'rake routes' are ' GET /auth/:provider/callback(.:format)' ' auth_failure GET /auth/failure(.:format)' 'signout GET /signout(.:format)' – Saravana Sep 01 '15 at 14:16
  • Have you setup different application on facebook for development server ? – Dipak Gupta Sep 01 '15 at 14:18
  • @Dipak I have tested some other projects but it is not related to rails. Is there anyway to debug online to check whether issue persist with my development server. – Saravana Sep 01 '15 at 14:22
  • I don't know any of this. But facebook provided for sharing console, So there must be a case they have for login/sign_up also. So you need to search for that. But do you have 2 app setup or only one? – Dipak Gupta Sep 01 '15 at 14:24
  • @Dipak only one. 'OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE' I have added this line in my 'development.rb in environment folder' , does it make an issue? – Saravana Sep 01 '15 at 14:32
  • Are you using heroku? If so, make sure you upload omniauth keys to heroku config. – miler350 Sep 01 '15 at 19:28

1 Answers1

2

Are you using devise gem for authntication? If yes then you shoundnt use 'initializers/omniauth.rb' but '/initializers/devise.rb' instead, along with 'omniauthable' in user model. A good tutorial: https://www.digitalocean.com/community/tutorials/how-to-configure-devise-and-omniauth-for-your-rails-application

tommybernaciak
  • 390
  • 2
  • 17