Search code examples
pythondjangofacebook-appspython-social-auth

How to test Facebook authentication using python social auth in localhost? Edited with more details


The question explains mostly everything. I am writing a Django app which will use Facebook authentication through Python social auth. I created an app using Facebook developers. The thing is, I don't have the domain set up with my website as I am still testing on localhost. I could not put in the localhost URL in the Facebook app settings. When I try to login through localhost, it says the URL must match with the domain.

What to do now? Without testing, I cannot host my website either as I am not sure if everything will work like i want it to.

EDIT:

I created a test app and was able to put localhost:8000 as the site url and localhost as app domain. However, the same problem still exists. It says that the 2 urls has to match or something. NOTE: In my local host, the login is 127.0.0.1:8000/login/facebook. And yes, I did update the ID and the app secret for my test app.

What to do now?


Solution

  • You should be able to create a test app within Facebook (There is a 'Create Test App') menu option. It may be that you need to first create an App, and once you have it, you will be able to create the Test App for it, but for sure you can create a Test App.

    On that test app, use http://localhost:8000/ as your local URL. Just make sure it is the exact same URL (i.e. you cannot have 'localhost' on Facebook, but then start the server for '127.0.0.1'). Note that the AppID and AppSecret you will use is of the Test App (not the production app).

    This should work. I have not used this for python-social-auth but use this to test with django-allauth, and there is no reason why it will be any different.