How can I add localhost:3000 to Facebook App for d

2019-01-17 06:17发布

I am working on a Rails 4 app. On my laptop, development is done at localhost:3000. The actual domain of the site is roomidex.com.

How can I set up a Facebook app so it works on production and development?

Here is the current configuration:

App Domains: roomidex.com

Website With Facebook Login: 
Site URL: http://www.roomidex.com

When I try to do a Facebook login on localhost:3000, I get this not surprising error:

{
   "error": {
      "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
      "type": "OAuthException",
      "code": 191
   }
}

8条回答
孤傲高冷的网名
2楼-- · 2019-01-17 06:49

Your error is saying

localhost URL is not allowed in the application

I know, FB does not give a s**t about explaining, what do to in those moments, however, as far as I am concerned, I have found workaround.

Basically, you need to "whitelist" locahost url in your app

Here is what you are going to do

  1. Go to the app edit/summary page
  2. In the fourth field App Domains, you should already have roomidex.com, so add another address localhost
  3. The urls mentioned above are only valid, if each one of them is put into tabs, where you set, how you app integrates with Facebook (website with facebook login, App on facebook, Mobile web, …)
  4. I do this: I put my working URL, in your case roomidex.com into Website with facebook login, and my test, localhost URL, either into App on facebook or Page tab
查看更多
forever°为你锁心
3楼-- · 2019-01-17 06:50

On the Facebook App page, click "edit App" then click "Advanced" in the left-hand navigation. Then for "Valid OAuth redirect URIs" add http://localhost:3000... or whatever you want the accepted redirect to be.

查看更多
Deceive 欺骗
4楼-- · 2019-01-17 06:56

Just create two applications.

One for testing and one for release. You cannot supply the app with separate URL configurations.

查看更多
干净又极端
5楼-- · 2019-01-17 07:00

June 2015

Go to My Apps > Settings > Basic

App Domains

  • localhost

Site Web

It didn't work with port 80 or without any port unfortunately.

查看更多
爷的心禁止访问
6楼-- · 2019-01-17 07:07

You can create a test app that's connected to your main app. On the Dashboard or Settings page for your main app. scroll down and you'll see "Test Apps" in the menu that runs down the left side of the page. The test app will inherit settings from the main app, but it will permanently be in development mode, and it will have its own ID.

More info on test apps here: https://developers.facebook.com/docs/apps/test-apps/

The protocol for setting up an app to work on localhost has changed. After you get your test app set up, this explains the steps for setting it up to work on localhost:

https://stackoverflow.com/a/24253054/2803458

查看更多
【Aperson】
7楼-- · 2019-01-17 07:09

Facebook now requires "Valid OAuth redirect URIs" to be https.

To use https locally (localhost:3000), I used [ngrok][1] which allows you to use https by providing a tunnel. To do this:

  1. I went to their website and downloaded their program
  2. I extracted the file for the program
  3. In my console, I went into the directory where ngrok was extracted to and entered 'grok http 3000' on my Windows machine, others may use './grok http 3000'
  4. After entering that, ngrok provided a https address which I put into the Valid OAuth Redirect URIs field in Facebook
  5. Then I started my server and was able to access it using that https address instead of localhost:3000
查看更多
登录 后发表回答