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
}
}
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.
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
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
- Go to the app edit/summary page
- In the fourth field App Domains, you should already have
roomidex.com
, so add another address localhost
- 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, …)
- 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
June 2015
Go to My Apps > Settings > Basic
App Domains
Site Web
- URL : http://localhost:8888/
- Mobile URL : http://localhost:8888/
It didn't work with port 80 or without any port unfortunately.
Adding localhost
to the Valid OAuth redirect URIs
in the test app did not work for me but adding 127.0.0.1
did.
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:
- I went to their website and downloaded their program
- I extracted the file for the program
- 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'
- After entering that, ngrok provided a https address which I put into the Valid OAuth Redirect URIs field in Facebook
- Then I started my server and was able to access it using that https address instead of localhost:3000
Just create two applications.
One for testing and one for release. You cannot supply the app with separate URL configurations.
Just edit your hosts file with your domain that pointing to localhost and it should work fine.