How to login using facebook in development environment using django social-auth?

泄露秘密 提交于 2019-12-07 03:59:26

问题


I'm using social-auth with my django web app. When I go to /login/facebook in the production environment, the user is able to login using their facebook data. However in my development environment when I access

http://localhost:8000/login/facebook/, 

I get an error saying

An error occurred. Please try again later.

API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.

I believe this is because the domain is localhost:8000. How do I fix this so I can login using facebook in my development environment?


回答1:


I had just seen an answer for it while reading the Heroku/Facebook documentation.

To do that, you must create a second app and link it to your localhost in order to test it locally.

You can find more info about it here: https://devcenter.heroku.com/articles/facebook#1-creating-a-development-facebook-app




回答2:


The easiest solution I found is to modify the hosts file to trick Facebook:

1/ Edit the hosts file

  • Open /etc/hosts
  • And add this line at the end: 127.0.0.1 dev.mydomain.com

2/ In the Facebook dev console (https://developers.facebook.com/apps/*********)

  • Select "Test apps" > "create a test app"
  • In "Settings" > "Basic" > Add the domain (dev.mydomain.com) into "App Domains" field.

Done!

cf: https://groups.google.com/forum/#!topic/django-social-auth/gB1D8ikgUwM



来源:https://stackoverflow.com/questions/13576551/how-to-login-using-facebook-in-development-environment-using-django-social-auth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!