[facebook] Facebook API error 191

I'm trying to integrate my project with Facebook. I'm taking baby steps at first and just trying to login, get a Facebook session, and get some user data. I'm developing it locally so my Facebook application settings are:

site URL: http://127.0.0.1:8888/mySite/

The canvas URL is the same as above. I haven't specified a site domain.

However, when I click on the login button, I get an error:

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.

At the moment I haven't written any server-side code to deal with redirects, etc. All I've done is add the JavaScript SDK based on the tutorial in Facebook for Websites.

What have I done wrong? It's obviously something to do with my Facebook application settings, but I can't see what!

This question is related to facebook facebook-javascript-sdk

The answer is


I was also facing the same problem when I am using the facebook authentication method. But I rectify that issue with following changes in Facebook api (Apps >> My App >> Basic).

  1. I removed the url which i have given in ===> App on Facebook (Canvas URLs)
  2. I gave site url only in ===> Website with Facebook Login option

Then i gave that AppId and App Secret in my webpage.

So by clicking on login button, It ask for access permissions then it redirect it to give url (Website with Facebook Login ).


Had the same problem:

$params = array('redirect_uri' => 'facebook.com/pages/foobar-dev');
$facebook->getLoginUrl($params);

When I changed the redirect_uri from the devloper page to the live page, 191 Error came up.

So I deleted the $params:

$facebook->getLoginUrl();

After the app-request now FB redirects to the app url itself f.e.: my.domain.com

What I do now is checking in index.php of my app if I'm inside FB iframe or not. If not I redirect to the live FB page f.e.:

$app = 'facebook.com/pages/foobar-live';
$rd = (isset($_SERVER['HTTP_REFERER'])) ? parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) : false;
if ($rd == 'apps.facebook.com' || (!isset($_REQUEST['signed_request'])))  {
    echo '<script>window.parent.location = "'.$app.'";</script>';
    die();
}

I have noticed also that even if you specify your website under secion - Website With Facebook Login -> Site url as e.g. http://example.com, but if your App Domains section is empty, and you open website as www.example.com you will get this error, too. To avoid it in "App Domains" section write example.com, that will allow subdomains, like www.example.com, something.example.com etc


in the facebook App Page, goto the basic tab. find "Website with Facebook Login" Option.

you will find Site URL: input there put the full URL ( for example http://Mywebsite.com/MyLogin.aspx ). this is the URL you can use with the call like If the APP ID is 123456789

https://graph.facebook.com/oauth/authorize?client_id=123456789&redirect_uri=http://Mywebsite/MyLogin.aspx&scope=publish_actions


This is just because of a 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/.

When I ran server as localhost:3000 it solved the problem.

As I mentioned, the site URL as localhost Facebook will redirect to the same, if we are running 0.0.0.0:3000, it will rise error that "Given URL is not allowed by the Application configuration".


Working locally... I couldn't get the feeds api to work, but the share api worked pretty much straight away with no problems.


I fixed this by passing the redirect url to the FacebookRedirectLoginHelper::getAccessToken() in my callback function:

Changing from

try {
        $accessToken = $helper->getAccessToken();
}
...

to

try {
        $accessToken = $helper->getAccessToken($fbRedirectUrl);
}
...

I am developing on a vagrant box, and it seems FacebookRedirectLoginHelper::getCurrentUrl() had issues generating a valid url.


For me, it was a missing app domain. Go into the app, and make sure that you have the root of your site set up as an app domain. See screenshot.

app domains is in the basic settings of your app


For me it's the Valid OAuth Redirect URIs in Facebook Login Settings. The 191 error is gone once I updated the correct redirect URI.

enter image description here


Something I'd like to add, since this is error 191 first question on google:

When redirecting to facebook instead of your own site for a signed request, you might experience this error if the user has secure browsing on and your app does redirect to facebook without SSL.