Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Authentication - Unsafe JavaScript attempt to access frame with URL

I am trying to implement Facebook Login System into my website.

While it try to connect to facebook, I get an error from console log:

Unsafe JavaScript attempt to access frame with URL https://s-static.ak.fbcdn.net/connect/xd_proxy.php?xxxxxxxxxxxxxxxx

I am using JavaScript SDK

I added this in the body tag:

<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : 'xxxxxxxxxxxxxx',
            status     : true, 
            cookie     : true,
            xfbml      : true
        });
    };
    (function(d){
        var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        d.getElementsByTagName('head')[0].appendChild(js);
    }(document));
    </script>

Facebook Login button:

<div class="fb-login-button"  data-perms="email">Login with Facebook</div>

I am testing from localhost - I have register my website on facebook develop apps (Site URL: http://localhost)

How to fix this problem? or should I use PHP SDK?

Edit: Same problem when I uploaded to server with public domain.

like image 472
I'll-Be-Back Avatar asked Nov 04 '11 16:11

I'll-Be-Back


4 Answers

The error that you see there is a non-fatal error. There is no workaround for this, as your browser is advising you that it is not a great idea to load JavaScript from foreign domains. Just ignore this message and look elsewhere for bugs if your scripts do not run. Sajith is also correct that you can't debug from localhost.

See here also, "Unsafe JavaScript attempt to access frame with URL..." error being continuously generated in Chrome webkit inspector

like image 192
user1122069 Avatar answered Sep 28 '22 08:09

user1122069


You can only use the same domain name in which you have registered with Facebook apps.

1. You need a public domain name (www.example.com).
2. You need to register with Facebook apps.
3. Get the 2 keys from the Facebook and use in the code:
    appId      : 'xxxxxxxxxxxxxx',
like image 32
Anto Avatar answered Sep 28 '22 09:09

Anto


Be sure to have this line on the top of your page (it works for me) :

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml">
like image 44
OlivierG Avatar answered Sep 28 '22 09:09

OlivierG


It is not possible to test all Facebook integration using domain localhost. You need to place your script in any public access domain and need to update the url in developer app settings page. The security error showing from JavaScript is due to this localhost access by facebook scripts

like image 36
Sajith Amma Avatar answered Sep 28 '22 09:09

Sajith Amma