How can I add localhost:3000 to Facebook App for development - ruby-on-rails

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
localhost
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.

Related

Authenticating my web site with MSA in Debug mode

Issue: On Launching the Web application in debug mode, Authentication is getting failed.
Detailed steps that i have implemented in debug mode:
1.Registered my application in Microsoft developer center
2.Modified my project URL to the same domain name, that i have used to register.
3.Used the Client ID and Secret key, from the registered application in web application.
4.Launched the sample application with the registered URL, in visual studio.
5.On clicking on Microsoft button, to authenticate- i am getting landed in error page.
6.Error URL: https://login.live.com/err.srf?lc=1033#error=invalid_request&error_description=The+provided+value+for+the+input+parameter+'redirect_uri'+is+not+valid.
+The+expected+value+is+'https://login.live.com/oauth20_desktop.srf'+or+a+URL+which+matches+the+redirect+URI+registered+for+this+client+application.
Queries:
1.Is it possible to verify the MSA Authentication in local environment in debug mode?
2.Does Microsoft authentication page re-directs to my localhost (at any case).
Your problem lies in your step 2. "2.Modified my project URL to the same domain name, that i have used to register."
To whatever URL you are using to register your app you have to append /signin-microsoft, i.e., if the URL for your app is, for example https://localhost:44300, then when you register your app with Microsoft the Redirect URI has to be https://localhost:44300/signin-microsoft. Therefore:
1.Is it possible to verify the MSA Authentication in local environment in debug mode?
Yes, follow my steps above (it has nothing to do with debug mode)
2.Does Microsoft authentication page re-directs to my localhost (at any case)
Yes, if you append /signin-microsoft to your app URL when registering it

Rails Heroku custom domain with Facebook login - Given URL is not allowed

I'm having trouble getting Heroku custom domain to play well with the Facebook oauth login
I am getting the error
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
which is examined in various threads including the Facebook one
https://www.facebook.com/help/community/question/?id=542958419109491
So far, my setup is this
the root
http://domain.com is redirect to to http://www.domain.com
The cnames have been changed for www.domain.com so it is an alias for my heroku app. Shows up fine.
https://devcenter.heroku.com/articles/custom-domains There does say
"Zone apex domains (aka “naked”, “bare” or “root” domains), e.g., example.com, using conventional DNS A-records are not supported on Heroku. However, there are alternative configurations that allow for root domains while still being resilient in a dynamic runtime environment."
but I don't know how this effects FB login
When I click the facebook login, it'll throw that error. I've tried various setups in my app settings including with and without the www
Right now, I've left it as
App domain: domain.com
Site URL: http://domain.com
Mobile site URL: http://domain.com
Embedded browser OAuth Login is enabled
(I've tried www for all the options above, but maybe there is a combination I haven't tried. I'm really just doing it randomly not knowing why one would work over another)
If I can't resolve this, I might try opening an issue on Facebook tomorrow.
This final combination seemed to work as my site is coming from www.domain.com
App domain: domain.com
Site URL: http://www.domain.com
Mobile site URL: http://www.domain.com
Embedded browser OAuth Login is enabled
Redirect uri in Advanced setting also added http://www.domain.com

How to Configure Facebook App For Devise/Omniauth on the current Facebook Apps site

I'm using this tutorial to setup simple OmniAuth authentication with Facebook for my Rails 4 app: http://sleekd.com/tutorials/setting-up-omniauth-authentication-with-facebook/.
The problem is that the tutorial is 3 years old and the organization of the Facebook App config site has changed significantly.
There no longer seems to be a "Site URL" box (where I would input http://localhost:3000). I also don't see "Site Domain" box (where I would input localhost).
In "Basic Settings" there is a box for "App Domains," but it won't accept localhost. Using localhost here results in the following error:
"This must be derived from Canvas URL, Secure Canvas URL, Unity Binary
URL, Site URL, Mobile Site URL, Page Tab URL or Secure Page Tab URL.
Check and correct the following domains: localhost"
Can anyone point me to where I should input these two bits of information with the most recent Facebook App config site?
You need to go into Settings on left sidebar, then + Add Platform. Choose Website and place
http://localhost:3000/
in Site Url field.
App Domains field can be blank.

Integrating Paypal Login in Rails app not working

I'm trying to integrate Paypal login within my Rails app and I can't make it work.
I was following the guide: http://cristianobetta.com/blog/2013/09/27/integrating-login-with-paypal-into-rails/
I created an application from the paypal developer site, and set the followings:
App return URL (test): http:/ /localhost:3000/auth/paypal/callback
App return URL (live): http:/ /localhost:3000/auth/paypal/callback
and I get the error:
"Relying Party Validation error: redirect_uri provided in the request does not match with the registered redirect_uri. Please check the request."
when I try to visit the URL:
http:/ /localhost:3000/auth/paypal
Interesting enough, I get the same error if I input my application credential in the official Paypal API integration tool:
https://devtools-paypal.com/guide/openid/ruby?interactive=ON&env=sandbox
Any ideas?
Thanks
This has changed a bit since the accepted answer, and will presumably change again soon... but here's how you do this now.
Log into developer.paypal.com
Click on Dashboard (https://developer.paypal.com/developer/applications)
Click your app name under "Rest API Apps"
Scroll to the box at the bottom of the screen labeled "Sandbox (or Live) App Settings
Set the Return URL (Where users will be redirected after test transactions)
Click save
NOTE
This Return URL must exactly match the redirect_uri that you pass in via querystring (so it's confusing as to why you'd need to pass it in in the first place)
GOTCHA
At this point in time, the Return URL can seemingly never be updated. In my recent experience, if you don't type it correctly the first time you save it, you will have to create a new app.
You need to set this value inside of your sandbox application on the developer website.
Log into developer.paypal.com
Click Applications
Under My Rest Apps click your App name
Click Edit next to App redirect URLs
Set the return URLs for live or test
Save
I resolved it by setting both the live and test redirect URLs to the same thing.
Plus, I ensured that I ticked to get Personal Information from the advanced settings panel, also adding URLs for privacy and agreement links.
The portal hung when set to localhost addresses for those links, so possibly PayPal tried to dereference them, so I put in real fake URLs.
I was encountering this issue myself, albeit in a Sinatra rather than Rails app - like you, I was using http://localhost:4567/auth/paypal/callback as the return URL - changing it to http://127.0.0.1:4567/auth/paypal/callback on the PayPal dev portal and accessing my app from 127.0.0.1 rather than localhost fixed it for me.

Facebook app - login through omniauth - OAuthException 191

I am facing with the problem:
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException",
"code": 191
}
I set up in my app the needed keys and tokens, in the Facebook's dev center I set up Site URL: to http://127.0.0.1:3001 and I am getting the error above. Also I tried to set up App Namespace: to http://127.0.0.1:3001, but I am getting error about bad address format...
When I tried to fill out he App Domain: and set there my localhost, again the error for the bad format...
What is the correct configuration the fabebook app with localhost?
You need to use urls, what I would do add this to your hosts:
127.0.0.1 dev-machine
127.0.0.1 dev-machine.com
Then in the facebook settings use
dev-machine.com as your App Domain
dev-machine.com:3001 as your Site URL
Yes in FB App you have to assign an IP Site/ App Domain.
Facebook matches this url with the url of the request where it came from.
You can not assign localhost or 127.0.0.1
You have to enter the IP address your server. Also if it is rails then call the site with your-ip:3000 instead of localhost:3000; I use 192.168.1.154:3000
Enter the same IP address in IP of the site and APP Domain in your FB APP Settings.
To get your IP run ifconfig command in terminal if it is Linux or ipconfig if windows.
let me know if it doesn't work.
in the facebook App Page -> the basic tab. find "Website with Facebook Login" Option.
you will find Site URL: input there put the full URL (i.e http:// localhost:3000 if you are in Development mode) [* note : not "App Domains"]
I encountered this error and it was incredibly frustrating. The solution? I wasn't actually passing parameters properly in the query string. When I manually built my URL and submitted it using the browser, everything worked fine. Crap.
So, essentially, if you're getting this error it may actually be a symptom of something totally unrelated to the redirect_uri -- it just happens to be the first error triggered when your parameters are messed up. I hope that saves you the hours I spent on this.

Resources