Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

localhost test setup - Facebook not allowing localhost

Tags:

facebook

oauth

Been trying to setup my Facebook app which I want to use for Logins to allow me to test it on my Mac's localhost. Facebook is throwing the error "App Domain: http://localhost is not a valid domain." when I try change App Domain of Site URL to localhost or 127.0.0.1

IS there any way to get the facebook login api to redirect the browser to my localhost after authentication?

like image 354
John Cogan Avatar asked Mar 05 '12 06:03

John Cogan


People also ask

How to test Facebook login on localhost?

Once you have your web app registered you can go to your app and click on add product. Add Facebook Login. Then enable Web OAuth Login and add your localhost in the textfield below and save, you should be able to access it. Attaching a sample screenshot of my facebook app.

What is valid OAuth redirect Uris Facebook?

A valid redirect URI is the URI within your application where Facebook will send you “stuff.” Meaning, the URI within your application where Facebook may send you an authorization code and an access token.


2 Answers

The way I do it is alias the site I'm working on to something like: http://sitename.loc, and then setup an app used specifically for testing with that as the domain.

An example of how to do this can be found here: https://stackoverflow.com/a/7493806/1056965

like image 185
Steven Avatar answered Oct 27 '22 01:10

Steven


On your local machine you have to setup hosts file to point your site name on local ip address. For example if you have to setup authorization with fb on site example.com put this record in your hosts file

127.0.0.1 example.com

And just start your site localy and facebook oauth will redirect you on example.com and you will get valid token localy.

For setup hosts file on windows help is on this link Windows Hosts Setup Linux help link Linux hosts

like image 42
Kalanj Djordje Djordje Avatar answered Oct 27 '22 01:10

Kalanj Djordje Djordje