I am using omniauth-facebook in my app. Everything works great on development. Once I upload to heroku (I made another facebook app so compensate for the url change in production). I am able to get to the facebook sign in page using mysitename.heroku.com/auth/facebook. However, after I log in and click the accept/allow button, there is a failure and the OmniAuth.config.on_failure function is processed and I go to my error screen.
Here is the error I get when I do [200, {}, [env['omniauth.error'].inspect]] in my .on_failure function:
#<OAuth2::Error: :
{"error":{"message":"Invalid redirect_uri: Given URL is not allowed by the Application configuration.","type":"OAuthException","code":191}}>
Here is the logs that seem to be relevant from the command: heroku logs
2013-08-27T22:44:20.842352+00:00 app[web.1]: Started GET "/auth/facebook" for 174.21.250.137 at 2013-08-27 22:44:20 +0000
2013-08-27T22:44:20.857734+00:00 heroku[router]: at=info method=GET path=/auth/facebook host=warm-anchorage-4172.herokuapp.com fwd="174.21.250.137" dyno=web.1 connect=10ms service=26ms status=302 bytes=262
2013-08-27T22:44:21.229031+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2013-08-27T22:44:21.228882+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2013-08-27T22:44:21.609111+00:00 app[web.1]: Started GET "/auth/facebook/callback?code=AQD4g5_eZRBzwOOvl_qI64mnKtk1b4048YuGXVyBjfxer9QrSBgiMwL8Nxsr0yducrL1DMfK3EdNS5E8qljb7BWvSoIoysfXF3tbIs6_7VkV2LiRVfrmZ8goku1MweG46hagJtatAJTbVfZkE6VL4t-pX169DCrn6TRhkfJoNAnRF8Xs2wHbPg1pwsUOOi_BJdRXNx9noZ8Cnc51unUVVKez-MStbD9OfDST5PNZNJzZJhaXiC_K2JpTg2S2z8tptsEAFf-gV5Rim86tN66FTCLG-HVhKBHp3bJgiYdC0160Kp8m0oKrO9lwMJQr6NBTOSw&state=fd82e1208e9848d0deda8271118799c38c4350f9c9f95fc6" for 174.21.250.137 at 2013-08-27 22:44:21 +0000
2013-08-27T22:44:21.609111+00:00 app[web.1]: Started GET "/auth/facebook/callback?code=AQD4g5_eZRBzwOOvl_qI64mnKtk1b404YuGXVyBjfxer9QrSBgiMwL8Nxsr0yducrL1DMfK3EdNS5E8qljb7BWvSoIoysfXF3tbIs6_7VkV2LiRVfrmZ8goku1MweG46hagJtatAJTbVfZkE6VL4t-pX169DCrn6TRhkfJoNAnRF8Xs2wHbPg1pwsUOOi_BJdRXNx9noZ8Cnc51unUVVKez-MStbD9OfDST5PNZNJzZJhaXiC_K2JpTg2S2z8tptsEAFf-gV5Rim86tN66FTCLG-HVhKBHp3bJgiYdC0160Kp8m0oKrO9lwMJQr6NBTOSwstate=fd82e1208e9848d0deda8271118799c38c4350f9c995fc6" for 174.21.250.137 at 2013-08-27 22:44:21 +0000
2013-08-27T22:44:21.700789+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path=/auth/facebook/callback?code=AQD4g5_eZRBzwOOvl_qI64mnKtk1b4048YuGXVyBjfxer9QrSBgiMwL8Nxsr0yducrL1DMfK3EdNS5E8qljb7BWvSoIoysfXF3tbIs6_7VkV2LiRVfrmZ8goku1MweG46hagJtatAJTbVfZkE6VL4t-pX169DCrn6TRhkfJoNAnRF8Xs2wHbPg1pwsUOOi_BJdRXNx9noZ8Cnc51unUVVKez-MStbD9OfDST5PNZNJzZJhaXiC_K2JpTg2S2z8tptsEAFf-gV5Rim86tN66FTCLG-HVhKBHp3bJgiYdC0160Kp8m0oKrO9lwMJQr6NBTOSw&state=fd82e1208e9848d0deda8271118799c38c4350f9c9f95fc6 host=warm-anchorage-4172.herokuapp.com fwd="174.21.250.137" dyno=web.1 connect=2ms service=114ms status=503 bytes=0
2013-08-27T22:44:22.939414+00:00 heroku[web.1]: Process exited with status 137
2013-08-27T22:44:34.222678+00:00 app[web.1]: [2013-08-27 22:44:34] INFO WEBrick 1.3.1
2013-08-27T22:44:34.222781+00:00 app[web.1]: [2013-08-27 22:44:34] INFO WEBrick::HTTPServer#start: pid=2 port=13228
2013-08-27T22:44:34.222678+00:00 app[web.1]: [2013-08-27 22:44:34] INFO ruby 1.9.3 (2013-06-27) [x86_64-linux]
Here is what my omniauth.rb looks like:
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
if Rails.env.production?
provider :facebook, "********72531693", "*******32c00b6bd32b70fa939e6a7c1"
{:scope => 'PERMISSION_1, PERMISSION_2, PERMISSION_3...', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
end
provider :facebook, "********45876931", "*******2abe337c16c135f06404c91a"
{:scope => 'PERMISSION_1, PERMISSION_2, PERMISSION_3...', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
end
OmniAuth.config.on_failure = Proc.new do |env|
UsersController.action(:omniauth_failure).call(env)
#this will invoke the omniauth_failure action in UsersController.
end
So I'm not for sure, but I feel pretty confident its a heroku issue since it works perfect in development on my localhost:3000. Both my apps are nearly identical on facebook for my dev and production version other than the host url. Since I am able to at least attempt to log in, I don't think it has anything to do with the facebook setup. I tried using both omniauth-facebook 1.4.0 and 1.4.1.
Adding my routes files, just in case somebody sees something that I don't see.
root 'welcome#index'
match '/signup', to: 'users#new', via: 'get'
match '/signin', to: 'sessions#new', via: 'get'
match '/signout', to: 'sessions#destroy', via: 'delete'
match '/about', to: 'static_pages#about', via: 'get'
match '/help', to: 'static_pages#help', via: 'get'
match '/auth/:provider/callback', to: 'sessions#createfb', via: 'get'