I have a development server (Java servlet container) running on my computer inside my private network (IP range 192.168.0.0 to 192.168.255.255). This development server executes my integration testing environment. This testing environment has its own Facebook App ID. Having the server run in the 192.168.x.y range allows my colleagues to test the website, login to my local website with their Facebook accounts etc..

At https://developers.facebook.com -> in the Facebook Apps settings -> located under "Basic settings" -> in the "Website with Facebook Login" field, I have set http://192.168.2.106:8080, as this is the address-port combination that my development server binds to.

Due to DHCP, my computer now has a slightly different IP address, namely 192.168.2.109. Whenever I start up my server and then try to do anything Facebook-API related (e.g. Facebook Login), I get the following error message from Facebook

Is there a way to have a Facebook App allow a "range of IP address websites with Facebook Login"? What other solutions can you suggest?

My colleagues shall be able to also start up the development server on their own machines, with their own private network addresses. Therefore, the same Facebook App ID shall work on different machines with different IP addresses and still be accessible to everybody inside the private network.

Notice that setting "Website with Facebook Login" to localhost makes the development server only available to the same machine it is running on. This unfortunately prevents colleagues from accessing this development server instance.

5 Answers
5

If you could get away of using localhost, then there is a very simple way:
Make the facebook app redirect to http://lvh.me:3000/ (or whatever port your server is listening on localhost). A benevolent developer owns the lvh.me domain and had the DNS setup to point to localhost. I've tried this and that's what I used for development testing.
Similarly, you could do stuff like that and points a DNS record of a domain you own to a range of local ip. I am not familiar with DNS so I am not sure how to set it up or if it's possible.

If you own a domain you could create a subdomain test.mydomain.com pointing to 192.168.2.109.

When your address should change again, you can change the entry accordingly.

There is no reason why a DNS entry could not point to a IP address from the 192.168 range. For someone outside your network it will not be of much use, because he can't access your IP address from the outside, but for your co-workers within the network it will work.

If a coworker wants to run the web app on his own PC, he can of course override this setting using his own hosts file.

This resolves back to the local machine, whatever its IP address is. I am assuming that your development server is running on your PC, using WAMP or something similar. I draw this assumption because you state that it must run on any laptop in any network environment.

Running the development server on localhost makes it impossible (?) for colleagues to access this server. Colleagues shall be able to access the server to sign-in with their Facebook account and test/play with the website.
–
AbdullDec 22 '12 at 11:29

So there is only one dev server, but you want people to be able to access it from anywhere? If that is the case, then you won't be able to use local addressing, because if a colleague is on a different network, it will have its own local network. The whole point about local addressing (192.168, 10.0 etc) is that all networks can have their OWN one. So are you saying you want devs from any network to be able to access your dev server? If that is the case you would need to use the external IP address of your network, and assign a specific port, then forward that port to your dev server.
–
Facebook AnswersDec 22 '12 at 15:47

As far as i know you cannot setup an IP range in your application setting, the redirect_uri is typically meant to handle urls with domain names, which is usually the case with with public websites.

The best way to avoid this problem is to make sure you local development server has always gets the same IP, which is generally a good practice if you are writing a server.
there are several ways to do it depending on the network setup, here are two option:

Bend the rules a little bit and setup your computer to claim an unused IP address. DHCP servers typically assign IPs in order (will start from 192.168.1.1 and work up to 192.168.254.254) so have your computer claim an IP in the higher part of the range (Ping the IP first to make sure it's not being used)

Here are the challenges / constraints I am facing: ANY developer must be able to start up the web application on one's OWN laptop in ANY network environment: at the workplace, at home, at a business partner's foreign network. Especially the foreign network use case makes it impossible to rely on a never-changing IP. And the "every-developer-can-start-up-the-web-application" use case makes it impossible to have only one IP/one central dev server.
–
AbdullDec 21 '12 at 21:19

If you're running on Windows you could try changing your hosts file in C:\Windows\System32\drivers\etc
and add your IP to an imaginary domain (your colleagues should do it too) and put that domain in Facebook Settings panel.
I'm not sure about this so tell me if it works :)

thank you for your solution. I thought through it. Changing the hosts file on every colleague computer in my private network isn't practical/possible (e.g. there are Android clients). Additionally, as much as I'm aware, Window's hosts file syntax does not support IP address wildcards. So when the server IP changes (e.g. due to DHCP, or server running on a different machine), I would need to update the hosts file on every machine.
–
AbdullDec 12 '12 at 17:23