0

Hi, i am puzzled about an Facebook-Error that has been recently popping up in my (newer) applications: The apps are working fine, until i disable sandbox mode and try to test the app as a normal user.

When clicking the login-button as normal user i get:
"An error occured. Please try again later" or sometimes : "API Error Description: An unknown error occurred Error Message: kError 1349045: An invalid Platform session was found.: An invalid Platform session was found." Sometimes the normal Permission-Dialog shows up, but after asking the extended permissions i also get the error...

Here is my Code:

window.fbAsyncInit = function() {
    FB.init({
appId      : 'XXXXXXXXXX', // App ID
        channelUrl : '//' + window.location.hostname + '/fbchannel.html', // Channel File
        status     : true, // check login status
        cookie     : false, // enable cookies to allow the server to access the session
        xfbml      : true  // parse XFBML
    });

};

    $(function(){
        $('.login').click(function(e) { 
            e.preventDefault();
            FB.login(function(response) {
                if (response.authResponse) {
                    FB.api('/me', function(response) {
                        $('#output').text('Good to see you, ' + response.name + '.');
                    });
                } else {
                    $('#output').text('User cancelled login or did not fully authorize.');
                }
            }, {scope: 'email, user_photos, publish_stream, user_likes'});

          // Additional initialization code here
        });
    });

// 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 = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
}(document));

I already tried enabling/disabling the enhanced auth dialog and the domain, facebook-app url and website is correctly set. For an admin of the app everything is working fine... Does anybody have an idea what i have done wrong or have the same problems?

Matschi
  • 1
  • 1
  • 1

1 Answers1

0

When you set up a facebook app you set up the urls from which it can be used. My guess is that you are trying to load this page of yours from a domain different than the one in the facebook app settings.

In the facebook app settings, you should have something set in the Website - Site Url, you then need to load the page with the js sdk from the same domain.

If you want, you can set up other domains in the App Domain in the settings page, but all of the domains there must be derived from your Site URL.

I created a very simple page that only loads the js sdk and then tries to call the FB.login, I then tested it on the same domain as it is set for that app in the settings page, everything worked great. I then copied that file to my localhost and gave it a try there, and indeed I received the same error you described.

Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299