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
}
}
Your error is saying
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
roomidex.com
, so add another addresslocalhost
app integrates with Facebook
(website with facebook login, App on facebook, Mobile web, …)Website with facebook login
, and my test, localhost URL, either intoApp on facebook
orPage tab
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.Just create two applications.
One for testing and one for release. You cannot supply the app with separate URL configurations.
June 2015
Go to My Apps > Settings > Basic
App Domains
Site Web
It didn't work with port 80 or without any port unfortunately.
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
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: