I am making an app for mobile phone, and I need to use Twitter and Facebook authentications.
My PC and my phone (Samsung Galaxy S2), on which I’m developing, are connected to one router.
My PC IP is 10.4.1.6. For Twitter authentication I just enter callback_url "http://10.4.1.6:3000" and everything works great, but for Facebook authentication I get:
"Invalid redirect_uri: Given URL is not allowed by the Application configuration."
I figured that if I can’t enter the IP of my router then I can edit my hosts files on my phone and my PC to point to my Rails server, but still, no luck.
When I try to enter "http://rails_dev_work_pc.com:3000", Facebook is telling me that the URL is invalid. How can I fix this error?
EDIT:
I tried to enter this:
- domain => “localhost.com”
- callback_url => “http://localhost.com:3000/auth/facebook/callback“
- in pc hosts => “127.0.1.1 localhost.com”;
- in phone hosts => “10.4.1.6 localhost.com
But I get the same error on my phone and my PC.
Also:
- domain => “localhost”
- callback_url => “http://localhost:3000/auth/facebook/callback“
- in my pc hosts => “127.0.1.1 localhost”;
- in phone hosts => “10.4.1.6 localhost
works fine on the PC, but on my phone I get the invalid URL error.
I’m out of ideas..
I’m using this setup:
In hosts file, route
localhosttolocalhost.com(or whatever you prefer). Now you should be able to use the following facebook app configuration:Please let me know if this works for you as well. Also, I found it very helpful to have 2 facebook applications – one used for production (pointing to your production app URL) and one for testing only (pointing to your URL configured in the HOSTS file). That way, you can make tests without disrupting your production app.
EDIT
Here is the final solution that @ExEdzy posted as an edit to this answer:
I Just changed in hosts files this “localhost localhos.com” to “ip localhost.com”
In my phone the ip is ip of my pc (10.4.1.6). And in my pc hosts file the ip is “127.0.0.1”
And in facebook:
– App Domains: => “http://localhost.com:3000”
– Site URL: => “http://localhost.com:3000/auth/facebook/callback”
Worked like a charm.