Facebook app oauth dialog error - facebook

I've been searching for the answer for days and I haven't been successful so I finally post to ask.
I'm developing a facebook app locally (it says I can develop locally in the guide) and having an issue when trying to authorize the app.
The following is the error msg I get when I direct to http://www.facebook.com/dialog/oauth?client_id=MY_APP_ID&redirect_uri=https://apps.facebook.com/MY_APP_NAME
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Error
An error occurred with Footmarker. Please try again later.
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Canvas URL & Site URL : http://localhost:8888/app/
I'm using EasyPHP hence port 8888. I tried changing port number to 80(default), 8080(one used in facebook guide) and no success.
I don't know if it's EasyPHP that causes the problem or simply I'm doing something wrong.
This thing drives me crazy. Help much appreciated. Thanks.

in this url: http://www.facebook.com/dialog/oauth?client_id=MY_APP_ID&redirect_uri=https://apps.facebook.com/MY_APP_NAME
You have to set redirect_uri=http://localhost:8888/app and authorize the localhost domain in your facebook app's settings (in the App domains field).
The Site URL & Canvas URL are used to check if the redirect_uri is not set to another URL for security reasons but the standard specify redirect_uri so they've let this parameter.
It's for this kind of error I built OAuth.io. We don't want more developers like you with a headache using OAuth.
using it is really easy:
OAuth.popup('facebook', function(err, res) {
// here, you can use res.access_token to make your API Call
// or...
res.get('/me')
.done(function(data) {
alert('Hello ' + data.name)
})
})
With this, you can't make mistake with URL anymore :)

The problem here is that your URL is not on the Internet. It is accessible from your computer only. You need a public URL.
Perhaps you can use dynDNS free to get onto the Net with your application from home.
Or, get a web server connected to the Net to host your App.
Best of luck!

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.
so becarefull with your website url you have specified in facebook app.
and the url you are running locally both should match
thank you

Related

How to redirect from Yahoo to my IOS app after authentication?

I am working on an app where I have to use Yahoo account to login.
I had gone through this link and followed the procedure as it was there.But I am unable to get back to my app after authentication.After googling I found an answer here.Here he said that "Add an URL Scheme in your info.plist file with the YOUR_APP_ID_OR_BUNDLE_ID" I did the same,but unable to redirect from yahoo to my app.If any one worked on this please help me.Thanks in advance.
This is what I had done in my URL Schemes
where JCzOzd44 is my app ID.
In yahoo account while creating the app.what should I give in "Application Domain"
I didn't work with the Yahoo! API yet, but in oauth it works like that:
Create an url scheme in your app. You can do that in the Info section of your project settings (URL types). Name the scheme whatever you want, for example your app id.
When you authenticate your app, you can pass a parameter named oauth_callback. Here you have to pass the name of the just created url scheme.
This should be it - when the login is ok on the Yahoo side, it will try to open the app that is registered for the url scheme it got as callback parameter.
UPDATE:
From the Yahoo! API documentation - this is the call you do when requesting the oauth token somewhere in your code (I filled in your url scheme as the callback, this is how it should look like):
https://api.login.yahoo.com/oauth/v2/
get_request_token?oauth_nonce=ce2130523f788f313f76314ed3965ea6
&oauth_timestamp=1202956957
&oauth_consumer_key=123456891011121314151617181920
&oauth_signature_method=plaintext
&oauth_signature=abcdef
&oauth_version=1.0
&xoauth_lang_pref="en-us"
&oauth_callback="JCzOzd44://"
Of course the request should be signed.
I have found the solution though with a little overheads.
Steps are: 1> Create a PHP script in you own server (say named, YRedirect.php).
2> Paste the following code in it-
CODE
<?php
$query = $_SERVER['QUERY_STRING'];
header("Location: com-mycompany-myapp://oauth-response?" . $query);
>
Where "com-mycompany-myapp" is your bundle identifier
3> Add an URL Scheme in your info.plist file with the YOUR_APP_ID_OR_BUNDLE_ID. That's it and you are DONE with the authentication problem.
In your code
[self.session sendUserToAuthorizationWithCallbackUrl:#"http://yourdomain.com/YRedirect.php"];
Then, register a custom URL scheme for your iPhone application from your Info.plist file, and then setup your server side script to redirect Safari back to your application via the URL scheme you just set up.
Thanks for this valuable information. Following your instructions I got the auth & call back working and the php page loads the app.

Facebook login only works when hosts is set to localhost?

Unfortunately I keep getting this error:
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException",
"code": 191
}
}
Login works however when my /etc/hosts file is set to: 127.0.0.1 [mysite].rhcloud.com, it only fails when I view the actual [mysite].rhcloud.com.
I am running the exact same application (on a different server) locally as the one I'm running on rhcloud. Specifically the local<->remote web-application directories are synced.
URL information
When attempting login remotely the URL looks like this; and fails with aforementioned error:
https://graph.facebook.com/oauth/authorize?scope=user_photos%2Cfriends_photos&redirect_uri=http%3A%2F%2F[mypublicipaddress]%2Fuser%2Flogin&response_type=code&client_id=[hidden]
Whereas attempting to login locally the URL looks like this; and works:
https://www.facebook.com/dialog/permissions.request?app_id=[hidden]&display=page&next=http%3A%2F%2F[hidden].rhcloud.com%2Fuser%2Flogin&response_type=code&perms=user_photos%2Cfriends_photos&fbconnect=1
OK, you seem to be doing this right, but there's one thing that sometimes trips people up, do both your redirect_uri and 'Website URL' field have a trailing '/'?
In particular, if the redirect_uri doesn't have the trailing '/' (or a filename, etc) after the domain name it doesn't always work
did you set your canvas URL/secure canvas URL in facebook app configuration. IF so, retry after removing them. Or try after making sure canvas URL should be correct.
Yes. The trailing / matters. Just check your these fields, and add that trailing / if it's not there.
But, to be honest, this is the first time I've seen something like this. Usually, we see Facebook logins failing on a local environment, but working just fine in production.
I was able to overcome exactly the same problem by accessing my facebook developer application account and changing the domain from localhost to the url of my application

Facebook mobile web application started throwing API Error Code:196

I have a web application which is configured as a canvas web application in facebook and also has provided a mobile url where mobile specific page is served from the web server. Application has been running for about 3 months and starting last week (I believe the issue started last week, there was no application deployment for the last 3 months ) when I access the application from my android phone , from the apps short cut in the native android facebook application , facebook throws the below error
API Error Code:196
API Error Description: Cannot redirect to desktop web canvas URL on a mobile device.
Error Message : redirect_uri is not owned by this application.
I can see that the request is coming to my web server and after I send the redirect url to the mobile, it throws the above error.
Since there was no code changes, I'm a bit confused about this new error, and googling this api error number didn't return any hits except for one japanese website where someone has mentioned about this error last week, but don't see any solutions.
The error message "cannot redirect to desktop web canvas..." seems to be sort of self explanatory but I can't figure out what is wrong , especially since the samething was working before, unless FB has changed any of their code which introduced a new issue or exposed an existing issue in my application configuration.
Lost 1 day on this, tried to read 2 Japanese (untraslated) blogs.. Then I figured it out my way!
In the app settings, do NOT enter the same url for the mobile app!
example:
normal canvas or website url:
https://www.stackoverflow.com/
(which will automatically bring you to https://www.stackoverflow.com/index.php)
mobile url: https://www.stackoverflow.com/mobile/
(which will automatically bring you to https://www.stackoverflow.com/mobile/index.php)
then make a "mobile" folder in your hosting root folder.
Now the only difference in the mobile folder will be the redirect uri.
I am using an url redirect, which is what facebook suggests.
https://developers.facebook.com/docs/reference/dialogs/oauth/
CRITICAL: make sure your redirect uri is not the canvas address but the webserver address!
wrong redirect uri: https://apps.facebook.com/mobile/yourappname/
correct redirect uri: https://yourwebsite.com/mobile/
this will make facebook think that it's an ad hoc mobile website! And everything will work as expected!
I had the same problem, and I solved it not set "redirect_uri" param, like this.
$url = $facebook->getLoginUrl(array(
'scope' => 'xxxx, xxxx, xxxx',
'display' => 'touch'
));
As you know, we can put "Canvas Page URL" value like
http://apps.facebook.com/[your app name space]
to "redirect_uri" param before, but I guess the spec of the param was changed at the middle of the last week.
I got a same error, "API Error Code:196".
Visit my page.
http://nobish.jp/facebook/app-install-api-error-code-196.html

Facebook Connect

I get two errors when I integrate FB with my site:
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.
In the address bar in the FB popup.. the api key and app id values are the same.
These errors don't ever happen together - it is either 1 or 2 never both.
what are you trying to do and in which language ?
the second error can be fixed by editing the site_url with the proper on which matches your website url in website tab in the developer dashboard of your application .
The redirect URL isn't on the same host that you provided when you registered your application. It has to be the same host - hostname.domainname.com. Any path or file under that is fine, but the host must match your app's settings on Facebook.
You probably didn't set the Site URL in your facebook application settings (edit your app->Website->Site URL) to the URL of your site.

facebook OpenGraph API on Rails (FBGraph)

I am trying to use FBGraph to let my app publish messages on the users wall. However, all of the APIs are kind of foreign to me and I am just trying to change things and see what happens. Right now, I am getting this error message
{
"error": {
"type": "OAuthException",
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration."
}
}
Does anyone know what it means by redirect_uri? What would it be on my Application Settings page on facebook?
Florin is correct. Just a note here.. when testing locally you will need to set it to:
http://localhost:3000/ (or whatever your app server port is)
Then when you move it to production, set it to your regular URL:
http://yourdomain.com/
I have a separate facebook app that I use in development to test, so I don't have to change back and forth between them and I set up the keys in a settings file, which has my tokens for development and production apps.
Anyways, looks like you are almost there. It is making it back to the callback url at least. Should be fine once you update the facebook_connect URL
I am not a facebook expert, but I hit the exact same problem as you a few hours ago when I was trying to login a user inside a web application with Facebook.
It seems that the redirect_uri which you specify in your call to "https://graph.facebook.com/oauth/authorize" must be on the same domain as the Connect Url of your application. (you can set that connect url from the Connect section in your application's settings)
Regards,
Florin
May need to check your Settings > Basic > Basic Info > App Domain. I believe hat needs to be set correctly for the redirect_uri as well.
I had the same issue.
In my case, I had configured site url on facebook as: "http://localhost:3000", it was a wrong URL to facebook.
The reason is, it lack of the / in the end of url, so the correct site url should be:
"http://localhost:3000/"
Just verify your 'Application ID'. In my case I had that problem because I was using ID from my other project that I was working on. Fairly obvious but I lost some time.
I had to make sure I had the scope in there too:
config.omniauth :facebook, 'xxxx', 'xxx', :scope => 'offline_access,email,publish_stream'
Plus you really need to make sure you wait a couple of minutes because it does take time to propagate..