Working with Facebook login from localhost

北慕城南 提交于 2020-01-10 13:08:04

问题


I have a React/Horizon app with facebook login. I am wondering if there is any option to work with facebook login from localhost?


回答1:


You need to register as facebook developer and create you app there. 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.




回答2:


So in my case doing the following things worked for me.

  1. Make sure your application is in development mode

  1. Make sure you don't have anything in Valid OAuth Redirect URIs when working from localhost

  1. Make sure you don't have anything in App Domains also

  1. Make sure you have entered localhost in your site url




回答3:


All these answers are good.

However I want to add information about how to create a Test app (as recommended by Facebook).

Go to the page to manage Facebook apps (you, the admin must be logged in): https://developers.facebook.com/apps/

Hover over the block containing your live Facebook app and click on the down arrow button that appears on the top right corner. Then select Create Test App from the menu.

The test app will be created with a snapshot of your production app's settings. After this, you can independently edit the settings of your test app without affecting your production app.

See the documentation here: https://developers.facebook.com/docs/apps/test-apps/

Regarding the rest of the setup:

  • keep your app in Development mode
  • go to Settings -> Basic (left hand menu) and
    • enter "localhost" for the App Domain
    • change your Site URL to the localhost version



回答4:


I would like to add an update: July 2019

Facebook now allow localhost automatically in development mode and it is blocked in production mode. All you have to do is turn on development mode in your app settings and you are good to go.

You do not need to add localhost as a redirect URL anymore.

Here you can see the error at the Redirect URLs when I'm trying to add localhost.




回答5:


So I also have problem with working with Facebook Login from localhost in React and Express and I got this info: "The method FB.login can no longer be called from http pages". After click login button, app just crashed. My solution to fix this mess, was delete Facebook cookie from this localhost page. After this, I still have this error about http, but I can proceed and test login options.

Other solution is working in incognito mode.




回答6:


After test I see that we don't need to setup anything in facebook app (even Site URL don't need to be localhost)

Just need to use https://localhost instead of http://localhost. Then login work and we able to receive response.

Note: If you see SSL warning after you enter https://localhost to browser. Just click on Advance -> Process to ... (unsafe)



来源:https://stackoverflow.com/questions/39800216/working-with-facebook-login-from-localhost

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