Facebook app - login through omniauth - OAuthException 191 - ruby-on-rails

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.

Related

Instagram oAuth returning "No matching code found" on one server

I'm currently receiving
{"code": 400, "error_type": "OAuthException", "error_message": "No matching code found."}
while attempting to get a user's access token on one of our servers. This is occurring while using the REST Client Chrome extension and from our web application, on one particular server.
I am able to receive the user's access token from my local machine and a different server using the same code and extension.
Could our IP have been blacklisted from receiving access tokens? Has anyone else run into this issue?
Thanks,
EDIT
Heard back from Instagram support, this was an issue on their end and has been fixed. Thanks for the help.
Yes your intuition is correct. It is likely that you made too many incorrect API calls that Instagram disabled your IP. I started dealing with Instagram API this week, at the beginning it was working but today I started getting the same error you got. The code also works fine locally or on any other machine. The only explanation to this is that my IP is blocked. Just switch your IP and you should be fine!
SOLVED:
The reason for this error is the ip address from which you are trying to connect to Instagram and get access_token. After contacting my network provider and changing my ip everything got fixed.
To figure out if your issue is caused by your local ip (not the server ip) try to connect to your app via mobile network or any other network different from yours:
- If it works you need to change your local ip.
-If it does not work - change your server ip cause it is probably banned by instagram for lots of malicious requests.
I was having the same trouble: users couldn't authenticate through Instagram and the error returned was "OAuthException" and "No matching code found." Started on 4/28/15 but didn't catch until two days later. Only in production, not staging, so it was almost certainly IP.
I posted to the Instagram developer help center (https://help.instagram.com/contact/438525166257277) yesterday at 7pm and the problem was fixed by this morning, with a cryptic email from their support at 11am ("The issue has been resolved").

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

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.

Facebook iFrame is pulling rails dynamic pages as 404 errors

I have a Facebook app page and a rails application. My rails application loads a dynamic page based on a key that is given. This works fine and dandy outside of my facebook app:
https://app.eventsent.net/event_lists/3d40ba2a4a10947c17c2337fba3421dd406cceb5?frame=true
However inside of Facebook the page is pulling up as a 404 error:
https://www.facebook.com/reynoldsdesignstudio/app_419134091467471
I have gotten around this issue by creating a static file within my system to be able to have facebook view it however this is not ideal as deploying the rails app with updates makes modifying these static pages a pain.
Any help on this would be great.
We got this figured out by changing the routes file to allow for a post request instead of just a get request
Your problem is not related to dynamic/static content. Also Facebook is showing a 501 error, not a 404. In short, your SSL cert is not valid for the staging.app subdomain you are pointing your Facebook page at.
Visiting your Facebook page (https://www.facebook.com/reynoldsdesignstudio/app_419134091467471) yields this error:
This webpage is not available
The webpage at https://staging.app.eventsent.net/event_lists/3d40ba2a4a10947c17c2337fba3421dd406cceb5.html might be temporarily down or it may have moved permanently to a new web address.
Error 501 (net::ERR_INSECURE_RESPONSE): Unknown error.
Note that the subdomain is staging.app. If you happen to be using Firefox, you get a nice error message the spells everything out:
This Connection is Untrusted
You have asked Firefox to connect securely to staging.app.eventsent.net, but we can't confirm that your connection is secure.
staging.app.eventsent.net uses an invalid security certificate.
The certificate is only valid for the following names:
app.eventsent.net , www.app.eventsent.net
(Error code: ssl_error_bad_cert_domain)
The easiest solution would be to get a WildCard SSL certificate that is valid for *.eventsent.net.
FYI, if you visit https://staging.app.eventsent.net/event_lists/3d40ba2a4a10947c17c2337fba3421dd406cceb5?frame=true, you will get a rather dire-looking warning from your browser. If you ignore the warning and tell the browser to accept the certificate, your Facebook page will then load fine in the same browser.

FB_Graph: An error occurred. Please try again later

I am using fb_graph for my rails app.
I just followed nov/fb_graph app.
It was working fine till last week, i was able yo login and could get user information.
But suddenly i am getting error.
I didnt change anything in my app.
my app_id, screat_id everything is correct.
Even i am getting error when i close that facebook error window like
Graph::Auth::VerificationFailed
Facebook cookie not found
Could any one got through this error
this just because of URL mistake
whatever website url is specified should be correct.
i mentioned website url as http://localhost:3000/ and domain as localhost
but in my browser i was running http://0.0.0.0:3000/ that was the actual problem so i ran server as localhost:3000 now its working fine. Because we mentioned site url as localhost fb will redirect to same, if we r running 0.0.0.0:3000 it will rise error that Given URL is not allowed by the Application configuration.
thank you

Facebook login on iPhone thowing errors

I have seen several past questions in SO, but none of them see to answer the question.
I am trying to have my iphone webapp use the Facebook login, but it fails everytime with a 191 error:
An error occurred with My Dev app. Please try again later.
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
My FB logging link looks like such:
http://m.facebook.com/dialog/oauth/?scope=email,user_birthday&client_id=1754645158****&redirect_uri=http://dev.someDomain.com&display=touch
Post trying to following the link the return uri is stripped from the url:
http://m.facebook.com/dialog/oauth/?scope=email,user_birthday&client_id=1754645158*****&redirect_uri=&display=touch
Per the fb dev site when specifying the domain:
If set, Facebook will enable authentication on all subdomains (e.g., "example.com" will enable *.example.com)
when I change it to my main domain, it redirects correctly.
What gives?
So I think I figured it out, adding www:
redirect_uri=http://www.dev.some
instead of:
redirect_uri=http://dev.some
Seems to fix this, now to finish the rest of the login...

Resources