facebookruby-on-rails-3herokudevisefbconnect

Error in Facebook Connect with Devise on Rails


I have spent a few hours trying to debug this issue and while there are several answers I couldn't get this to work and don't understand a few things.

I have Facebook login implemented with Devise on my Rails 3 App deployed on Heroku. I have this working fine on localhost and I had this working on production as well. I don't think I changed anything but I found out that the Facebook login was broken and can't figure out how to fix this. A few clues that may ring a bell for some -

The url I am getting where the error shows is below with the error message that many others posts show. What I find strange is the following -

  1. Decoding the url below the redirect_uri has a port number http://www.mygreenneighbor.com:24745/auth/facebook/callback&scope=email,offline_access&

I don't think the app on Heroku is listening at this port 24745 (which btw changes when I try it after sometime) and I haven't noticed that before - is that expected?

  1. When I make changes to my Facebook app and change the site url that change doesn't show up in the redirect uri. Does it take time for FB changes to take effect?

https://graph.facebook.com/oauth/authorize?client_id=159903734070492&redirect_uri=http%3A%2F%2Fwww.mygreenneighbor.com%3A24745%2Fauth%2Ffacebook%2Fcallback&scope=email%2Coffline_access&response_type=code

{ "error": { "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.", "type": "OAuthException", "code": 191 } }

Thanks for your thoughts/guidance. -S


Solution

  • After a lot of digging around, I cam across this article

    http://www.kbedell.com/2011/03/08/overriding-omniauth-callback-url-for-twitter-or-facebook-oath-processing/

    I realized that I had switched to using Passenger as my web server from a singled threaded/process WebRick webserver. Passenger has more than one process running on the same dyno and apparently it sends a callback url with a port number in the request. To override that I used the advice in the above article and set the following in my applicaiton.rb file

    OmniAuth.config.full_host = "http://www.mygreenneighbor.com" and it solved the problem.

    Hope this helps someone.

    -S