Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 519
musoNic80 Avatar asked Jan 14 '11 13:01

musoNic80


4 Answers

UPDATE:
To answer the API Error Code: 191
The redirect_uri should be equal (or relative) to the Site URL.
enter image description here

Tip: Use base URLs instead of full URLs pointing to specific pages.

NOT RECOMMENDED: For example, if you use www.mydomain.com/fb/test.html as your Site URL and having www.mydomain.com/fb/secondPage.html as redirect_uri this will give you the 191 error.

RECOMMENDED: So instead have your Site URL set to a base URL like: www.mydomain.com/ OR www.mydomain.com/fb/.


I went through the Facebook Python sample application today, and I was shocked it was stating clearly that you can use http://localhost:8080/ as Site URL if you are developing locally:

Configure the Site URL, and point it to your Web Server. If you're developing locally, you can use http://localhost:8080/

While I was sure you can't do that, based on my own experience (very old test though) it seems that you actually CAN test your Facebook application locally!

So I picked up an old application of mine and edited its name, Site URL and Canvas URL: Site URL: http://localhost:80/fblocal/

I downloaded the latest Facebook PHP-SDK and threw it in my xampp/htdocs/fblocal/ folder.

But I got the same error as yours! I noticed that XAMPP is doing an automatic redirection to http://localhost/fblocal/ so I changed the setting to simply http://localhost/fblocal/ and the error was gone BUT I had to remove the application (from privacy settings) and re-install my application and here are the results:
alt text

After that, asked for the publish_stream permission, and I was able to publish to my profile (using the PHP-SDK):

$user = $facebook->getUser();
if ($user) {
    try {
        $post = $facebook->api('/me/feed', 'post', array('message'=>'Hello World, from localhost!'));
    } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}

Results: alt text

like image 54
ifaour Avatar answered Oct 31 '22 21:10

ifaour


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

like image 28
Mike_K Avatar answered Oct 31 '22 22:10

Mike_K


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".

like image 8
devudilip Avatar answered Oct 31 '22 21:10

devudilip


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 ).

like image 2
ShivarajRH Avatar answered Oct 31 '22 22:10

ShivarajRH