Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook API Logout of my app but not facebook

How do I make a logout using Facebook's api log me out of my app (a website), but keep me logged into facebook.com?

This logs me in alright:

 window.fbAsyncInit = function()
{
        FB.init({
            appId      : '<?= APP_ID ?>',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true,
        });

    FB.Event.subscribe('auth.login', function(response)
    {alert(response);
            window.location = 'http://reviewsie.com/accounts/facebook';
        });

    };

  (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));

But then I click logout on my site which I kill my session to my app. Then when you click on the fb:login-button again, it just opens and closes and doesn't do anything because I'm still connected to facebook. I want it to redirect.

But if when I logout I also use Facebook::logoutUrl it logs me out of my app AND facebook which is not what I want.

like image 800
cdub Avatar asked Feb 08 '12 07:02

cdub


People also ask

How do I logout of Facebook without the app?

Go to the Facebook website on the same browser where you had previously logged in. 2. In the top right hand corner, click the downward-facing arrow. A dropdown menu will appear and at the very bottom of that menu, you'll see "Log Out."

How do I logout of my Facebook app on the business?

Open the Facebook app. Tap. . Scroll to the bottom and tap Log Out.


2 Answers

A bit late but might help someone. You can revoke app permissions which effectively logs them out of your app. Here's the code:

FB.api('/me/permissions', 'delete', function(response) {
    console.log(response.status); // true for successful logout.
});
like image 197
James Avatar answered Sep 18 '22 09:09

James


This works for me:

window.fbAsyncInit = function() {

FB.getLoginStatus(function(response) {

    FB.api("/me/permissions", "delete", function(response){ 


    });

});

}
like image 36
Phil LaNasa Avatar answered Sep 19 '22 09:09

Phil LaNasa