I'm currently developing an app which uses facebook Open graph API. Using localhost works fine with facebook authentication but when you want to use graph api then facebook needs access to the webpage, so that it can parse open graph meta tags.
The solution to this problem is either deploy your app online or allow localhost tunneling so that facebook can access it. I prefer localhost tunneling when working in my development environment.
I use ngrok. ngrok securely exposes a local web server to the internet and capture all traffic for detailed inspection and replay and it worked well with facebook.
ngrok is easy to use and it takes just 2 minutes to signup and expose your webserver. Sign up is not required but it doesn't take much time so I did.
1. Download ngrok
I downloaded ngrok on my mac but it's available for windows and linux as well. it's just a small zip file, just takes few seconds to download.
2. unzip it
3. Run it
ngrok -authtoken your_auth_token port
in above command yourauthtoken is your authentication token and port is the port which you want to expose.
Tunnel Status online Version 1.6/1.5 Forwarding http://9d322c2.ngrok.com -> 127.0.0.1:80 Forwarding https://9d322c2.ngrok.com -> 127.0.0.1:80 Web Interface 127.0.0.1:4040 # Conn 0 Avg Conn Time 0.00ms
where http://9d322c2.ngrok.com is the url which you can use to access your local web server. I have closed this tunnel, So you won't able to access this url, it's just for example purpose here.
Thanks for reading.