Facebook App Error 191: URL not owned by Application – try this…

I’ve recently had feedback from one or two “Facebook Application Development” course students who’ve ran into the infamous “error 191″ problem when trying to run their Facebook Apps.

Normally this error is caused by using an incorrect URL in the ‘redirect_uri’ parameter for getLoginUrl when using the PHP SDK, for example:

$loginUrl = $facebook->getLoginUrl(array('scope'=> 'user_checkins','redirect_uri'=> $app_url));

Another potential cause of this error is mixing your http: and https: URLs or assigning a http: URL to this parameter when the user is actually using a secure https: URL to access your App.

When I recorded the Facebook course the need to check the protocol and assign the correct http: or https: URL simply wasn’t there. Now we need to do this. Many users have switched over to using Facebook over a secure connection and Facebook will also switch off support for http:-only Apps anytime soon (as usual, no exact date).

Here’s a little snippet you can use to check for the protocol being used and assign the ‘redirect_uri’ correctly:

$protocol = ($_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";

Then simply prepend $protocol to your ‘apps.facebook.com/…’ string to form the URL.

If that’s not the issue and all seems to be fine, all URLs look right and you simply can’t see what else could be wrong, then don’t panic: Stop pulling your hair out :-)

Have you set up an App Namespace in the Developer App?

It turns out that, if you don’t set this and use the APP NAMESPACE to refer to the App, you can get the dreaded 191 error. Set it and use it in your redirect_uri instead of the FB-generated App ID number.

When I recorded the course, the App Namespace was generated and used by default to reference the App. Hence the problem didn’t arise. This is one of the things that have changed since the course was recorded.

To summarise:

  1. Check that your URLs and protocols match – both in the Developer App and in your code.
  2. Assign the correct protocol when assigning the ‘redirect_uri’ parameter for getLoginUrl().
  3. Use the App Namespace and not the App ID to reference your App on apps.facebook.com

There have, of course, been many more changes in the World of Facebook App Dev since I recored the course – even since it’s release. Watch this space for more updates over the next few weeks!

Happy Facebook App-building!


tags: , , , ,

3 responses to “Facebook App Error 191: URL not owned by Application – try this…”

  • Can you do this:

    $app_url = “//apps.facebook.com/(url)”;

    That’s how you make a Jquery cdn request to either the https or http version when you use the Google CDN if you want to be protocol agnostic.

    My problem is actually the Oauth dialogue, it on’t let me in and it’s not throwing any real error message.

  • Hi Mike

    To be honest, I’ve not tried that. I guess you have by now – sorry for the late response. Did it work?


  • You know what I was just about to write a blog article about this, NOWHERE and I mean NOWHERE do the docs say this is required, I had the url etc all set right, purchased an SSL cert, checked and double checked everything. It was purely by chance that we noticed the app namespace was blank.

    The fact that facebook just blurge out error 191 when its clearly the only thing wrong is just crazy. Wish I found this two weeks ago.