Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FB.init(...) error: "Given URL is not allowed by the Application configuration."

Tags:

facebook

init

I'm trying to follow the tutorial here. But when I call FB.init(...) with what appears to be valid and correct parameters I get the error message: "Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains." I have searched (1 2) for this error, but everyone else seems to be having trouble simply setting the Site URL for their Facebook Application configuration. I'm 99% certain I have set this correctly - but obviously I'm doing something wrong.

Here is my code that is causing problems. I have replaced some of the info with "XXX" and "YYY" for privacy reasons.

<html>
<body>
<h1>Facebook</h1>
<div id="fb-root"></div>
<script>
  // Additional JS functions here
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'XXX', // App ID
      channelUrl : '//YYY.com/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

  };//window.fbAsyncInit()

  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "http://connect.facebook.net/en_US/all/debug.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));
</script>
</body>
</html>

Notice that I had to change the js.src parameter near the bottom of the code from the example given in the tutorial. I doubt this is causing my specific problem, but casts some concern on the quality of the code in the tutorial. (I hate it when tutorial code doesn't work - what's the point?)

You can see in the code above I have replaced the root of my domain name to "YYY". Keeping with this simple replacement here are some of the values from my Facebook Application configuration:

App ID: "XXX"
Display Name: "[blah blah blah]"
Namespace: "YYY"
App Domains: "YYY.com"
Sandbox Mode: "Enabled"
Canvas Page: "http://apps.facebook.com/YYY"
Canvas URL: "http://YYY.com/canvas/"

I'm not sure what other detail you may need to help me with this. All of the URL's listed are functional. Thanks for any help!

like image 964
Carl Rossman Avatar asked Nov 29 '12 02:11

Carl Rossman


1 Answers

Notice that I had to change the js.src parameter near the bottom of the code from the example given in the tutorial.

Why? Are you testing by just calling your page in the browser from the file system, and not over HTTP via a local web server?

If the latter is the case, then you have no “domain” that Facebook could verify your request origin against. Set up a local web server, call your document via it, and try again,

like image 118
CBroe Avatar answered Oct 17 '22 06:10

CBroe