I'm trying to log out of a website i've created with Facebook integrated. Logging in works fine, but when I want to log out Firebug consistently gives me this error:
FB.logout()
called without an access token.
I'm using the Facebook JavaScript SDK, and the code I've got to logout looks like this:
$(document).ready($(function () {
$("#fblogout").click(facebooklogout);
}));
function facebooklogout() {
FB.logout(function (response) {
}
)};
This is the logout code specified at the Facebook Developers Documentation just with a button being assigned the method on document.ready
Before this code I have the FB.init()
method, that all runs fine.
If anyone's got a solution as to why FB.logout doesn't have an access token, it'd be appreciated.
The error says that you don't have an access token, you have to check for one using the FB.getAccessToken() function.
If there is no access token the function returns null. See example below:
I went for the less trivial solution:
I've tried something like this:
To logout from the application which uses facebook graph API, use this JavaScript on the logout page just after the
<form>
tag:The code works and is live on my site.
Should be something more like this. There was a change to the JS API where you have to use authResponse instead of just session.