FB.logout() called without an access token error - facebook

I have upgraded my js FB Connect to oauth version & when I am trying to logout from FB programatically using FB.logout() method, I am getting error like
"FB.logout() called without an access token"
What is the problem behind this? I saw one thread over here but it didn't worked for me. Please help me if someone has found solution for this. Thanks.

This is what i've used before.
//check if logout is
FB.getLoginStatus(function(ret) {
/// are they currently logged into Facebook?
if(ret.authResponse) {
//they were authed so do the logout
FB.logout(function(response) {
//do your stuff here.
});
} else {
///do something if they aren't logged in
//or just get rid of this if you don't need to do something if they weren't logged in
}
});

I've encountered this problem and fixed it.
This happened for me when a user had already logged out and I tried to fb.logout() method again. It seems in the following code:
FB.logout(function(response)
{
console.log(response.status);
}
);
response.status will say 'connected' even if the user is logged out, due to some caching issues or some other bug. Hence its better to use authResponse to determine whether or not the user is logged in. I.e:
FB.logout(function(response)
{
if (! response.authResponse)
//disable logout button
}
);

Related

How to do logout with Meteor js to a user logged with facebook?

In my mobile app made with the meteor js, when the user login with facebook and try log out, when the user access the app again he has logged automatically. By the way, the user was not logged out.
This is my log out code:
Meteor.logout(function () {
// redirect to login page
});
Try removing the meteorlogintoken from local storage. You may also need to remove the resume token from a user in the users collection (if one exists).
Can’t say for sure as I don’t use Facebook with meteor but the above works for a standard meteor user
To further help diagnose the problem, you can test if the call to Meteor.logout returned an Error in the callback, something like:
Meteor.logout(function(err) {
if(err) {
console.error(err);
} else {
// Re-direct to login page
}
);
See: https://docs.meteor.com/api/accounts.html#Meteor-logout

PhoneGap; FB Connect Plugin (Android OS): Re-Authorizing FB App every post

I created an Android App with PhoneGap:Build and the FB Connect Plugin. The app works fine and the FB Plugin, too. Just one tiny thing isn't working yet. I won't to post something after submiting a button which works, too. At the first time the user has to login and grant permissions to the FB App and them the post is published. That's the way it should be. And the next time the user submits the post should be published without the whole permission thing but this isn't working!? FB shows a message like "You already granted permission ... to the app." and the user has to push the Ok-button before the post is published???
Because I still haven't found an answer for my question, maybe I just do something wrong in my FB Javascript call? Here is the current code:
FB.login(function(response) {
if (response.authResponse) {
var data = {
...
}
FB.api('/me/feed', 'post', data, function(response) {
// Callback
if (!response || response.error) {
// ERROR
}
});
} else {
// ERROR
}
}, {scope: 'publish_stream'});
Well, to better understanding here a picture of the screen that apears every post:
http://i.stack.imgur.com/bZrde.png
Thx,
Daniel
I think the solution to this problem is to not include the login request every time you want to post something. You can check login status, and/or permissions, without performing a login. Then, if the user is not logged in, do the login first, and come back to the new post action.

Facebook application: FB events work only for first time

I'm using the following code to subscribe to fb login and logout events.
FB.Event.subscribe('auth.logout', function(response) {
RefreshPageOnFBStatusChange(response);
});
FB.Event.subscribe('auth.login', function(response) {
RefreshPageOnFBStatusChange(response);
});
function RefreshPageOnFBStatusChange(response)
{
alert(response.status);
}
I want to redirect users to different pages when they are logged in or logged out. The function I'm using here gets called only during the actual page load, and never after that. I have a fb-like, fb-share and live stream plugin on a page. When I login and logout of live stream, nothing happens. Help!
Please modify your question and provide all FB-related code.
This may answer you question:
Facebook FB.Event.subscribe event does not fire:(
For User Status you can use if(FB._userStatus == "connected"){} to check user is login or not And for Logout & login you can use following simple code
FB.logout(function(response) { window.location = redriect_uri;
});
It seems like these events don't fire when you use the live chat plugin because it has its own way of handling the login and logout. What I had to do to solve this problem was to set a timeout of 5 seconds and call a javascript function that did a FB.GetLoginStatus, and based on what it was I would refresh the page. Not the best way of doing it, but I was left with no choice.

Detecting if a facebook user allowed or disallowed login

I am using FB's Javascript SDK using the login-button:
<fb:login-button onlogin="onFBLogin();">
How can I detect within onFBLogin() if the user did log in successfully ? Currently it is called everytime, no matter what the user chooses.
Thanks,
Meir
I think the first parameter passed into onFBLogin() is going to be either a response or a session object. So check to see what the value of response or response.session is.
Also, have you played around with FBJS's login event handling?
If using FB.login:
FB.login(function(response) {
if (response.session) {
// user successfully logged in
} else {
// user cancelled login
}
});
But since you're using an fb:login button, you can try to subscribe to the login event:
FB.Event.subscribe('auth.login', function(response) {
// do something with response.session
});
I haven't tried this myself via fb:login button, but hopefully this will get you on the right track.

Facebook - Permissions Dialog on IE7

This works well in Chrome/Safari/Firefox etc. But I can't get it working in IE7. Any ideas?
I have a cross-domain channel set up, and that seems to be working elsewhere.
I bring up a permissions dialog like this:
o.method = 'permissions.request';
o.perms = 'email';
o.display = 'dialog';
FB.ui(o, function(res) {
// do something
});
In IE this appears as a popup, but after granting the permission, the popup does not close - and redirects to my cross-domain channel url.
Any ideas how to automatically close the dialog?
A second problem is if I manually close the dialog, the callback is invoked, but without the granted permission. Could be related to the first point, but I'm not sure.
Thanks!
I have a suspicion that permissions.request is a deprecated method. The correct way to ask the user for permissions now is the FB.login() method.
For example:
FB.login(function(response) {
if (response.authResponse) {
// logged in
} else {
// user cancelled login or did not fully authorize
}
}, {scope: 'email'});