0

I had this problem initially when I started the Facebook integration of our site. After doing some searching, found the solution and fixed it.

Now, a few months later, it has just stopped working. Nothing was changed in either the javascript code or the app settings on the Facebook developers site. I once again set about searching, and found the same answers as before: Site URL must match redirect_uri etc.

I currently have the App Domain: "domain.com"
And the Site URL: "http://www.domain.com"

Error given:

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.

I'm at a loss as to what has happened. Has Facebook changed their API? (I did check their documentation, and it's still the same).

Any help would be greatly appreciated. Javascript code below:

var publish = {
    method: 'feed',
    redirect_uri: 'http://www.domain.com',
    link: 'http://www.domain.com',
    picture: 'http://pathtoimage/logo.png',
    name: 'Name',
    caption: 'Title',
    description: 'Description, blah blah'
};

function fbcallback(response) {
    // do stuff here
}

FB.ui(publish, fbcallback);

Thanks

EDIT:
I checked the timestamp and the JS file hasn't been touched since the 16th of March, neither has the App Settings on Facebook, and my colleague tested this just a week ago (was still working then)

Nathan Glenn
  • 31
  • 1
  • 6
  • Tip: You don't have to write html tags on Stackoverflow (`
    ` etc). No reason to "fake" the URL with `http` either.
    – timss Apr 20 '13 at 00:31
  • @timss - sorry, first time poster, the link kept changing to clickable, wasn't sure how to stop that – Nathan Glenn Apr 20 '13 at 00:41
  • @natahn-glenn Of course, no problem. Take a look at http://stackoverflow.com/editing-help for more information. – timss Apr 20 '13 at 00:45
  • is `'http://pathtoimage/logo.png'` inside `domain.com`? try commenting it out and see if it changes anything.. – asifrc Apr 20 '13 at 05:57
  • @asifrc - Unfortunately didn't change anything :( The path to the image uses an IP address atm, but commenting it out didn't work. I tried it with the Site URL in App Settings as both ' http://domain.com/ ' and ' http://www.domain.com ', making sure the redirect_uri matched this, neither worked. – Nathan Glenn Apr 20 '13 at 06:06
  • have you checked out http://stackoverflow.com/questions/4691782/facebook-api-error-191 ? – asifrc Apr 20 '13 at 06:11
  • @asifrc - yep, I read through it again anyway, just to double check I didn't miss anything. I appear to have the Site URL set correctly, but still not working, neither locally nor on the server. I also tried commenting out the redirect_uri, nothing either. Just don't know how it can be working just last week, and not now. Do you know if FB have changed anything in the last week? – Nathan Glenn Apr 20 '13 at 06:30
  • Just thought I'd try something else on that link, just for the heck of it. I changed the Site URL to http://localhost:8080/ and App Domain to localhost, then redirect_uri to http://localhost:8080/ and it worked. Any ideas why it works for localhost but not for a real site URL? – Nathan Glenn Apr 20 '13 at 06:32
  • This is some weird stuff.. is there such thing as a true anomaly in programming? Or is there always an answer, lurking just out of sight? lol. I am not aware of any changes and have no idea why that worked. Does changing it back make it not work again? – asifrc Apr 20 '13 at 06:49
  • @asifrc - yeah, stops working. Btw, just happened to have the Chrome Dev window in front of me when trying again, and one of the "info" icons appeared with the message "When using FB.ui, you should not specify a redirect_uri". Never seen this before. I did some searching, and everywhere it says it must be there, even FB docs has it. Weird stuff indeed. Really confused now... – Nathan Glenn Apr 20 '13 at 06:54
  • I hear it takes forever, but perhaps file a bug report? – asifrc Apr 20 '13 at 06:57
  • @asifrc - I'm just going to try one more thing (will take a couple hrs), then if that doesn't work, I'll raise it as a bug. I'll let you know how I go... – Nathan Glenn Apr 20 '13 at 07:29
  • @asifrc - Thanks very much for your help, it did work. I've posted what I did below, let me know if it doesn't make sense. – Nathan Glenn Apr 20 '13 at 08:50

2 Answers2

3

RESOLVED:

For others that are having the same problem, here's what worked for me.

It appears that FB have tightened their security, which is why it was originally working.
We were working on a new release, and were using the IP address instead of the domain to access the site. A new message I hadn't seen previously started appearing in the dev console:

When using FB.ui, you should not specify a redirect_uri.

Looks like the FB api now checks the URL domain in the address field of the browser (rather than the redirect_uri) against the Site URL in the Facebook App Settings. Tested this by temporarily pointing our domain to the IP address, and running the Facebook api code via the domain loaded site, and it worked. So while we're testing before the release, I'll use http://localhost:8080 as the Site URL, then update it to the site's domain when it goes live.

Thanks to the people who helped to point me in the right direction!

Nathan Glenn
  • 31
  • 1
  • 6
  • well, probably the 'redirect_uri' should (or must?) be used only when the FB.ui will be launched with 'display:popup' because the UI will be launched in another window, while when you use the standard 'lightbox' UI it create some problem! – Alberto Fecchi Apr 20 '13 at 11:38
0

Try to check if in your app settings (on Facebook Developers) you have set:

  • 'App domain' with the domain where you're using the app
  • Check the 'Website with Facebook Login' option and then set the domain there
Alberto Fecchi
  • 1,705
  • 12
  • 27
  • Thanks Alberto, I currently have the App Domain set to "domain.com" and the Site URL (under 'Website with Facebook Login') set to "http://www.domain.com" (of course the word domain is replaced with the actual domain). Still no luck. – Nathan Glenn Apr 20 '13 at 03:08
  • have you also checked if the protocol (http / https) is the same for the domain and the redirect_uri? not sure if it's the problem, but it could be a possibility – Alberto Fecchi Apr 20 '13 at 03:14
  • Do you mean the App Domain setting on Facebook? It won't allow any protocol info. – Nathan Glenn Apr 20 '13 at 03:16
  • Also tried adding and removing the 'www', as well as going as far as using the direct IP address. (App Domain doesn't allow IPs either) – Nathan Glenn Apr 20 '13 at 03:30
  • try to set the urls in your app settings (on FB Developers) WITHOUT www, just 'domain.com'... already done? p.s. note that the modifies may take some minutes to be avaible, make some try and wait – Alberto Fecchi Apr 20 '13 at 03:35
  • Changed it to - App Domain: domain.com Site URL: http://domain.com (with http://) Still no luck – Nathan Glenn Apr 20 '13 at 04:01
  • This is really confusing me. I checked the timestamp and the JS file hasn't been touched since the 16th of March, neither has the App Settings on Facebook, and my colleague tested this just a week ago (was still working then). – Nathan Glenn Apr 20 '13 at 05:27