Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've noticed that if a user is logged out of facebook (say they login from another computer or browser) while they are connected to the site then I get an error as follows:
Facebook API exception Session key invalid or no longer valid.
#0 C:\<path_to_drupal>\drupal\sites\all\modules\fb\facebook-platform\php\facebookapi_php5_restlib.php(1056): FacebookRestClient->call_method('facebook.friend...', Array)
#1 C:\<path_to_drupal>\drupal\sites\all\modules\fb\fb.module(460): FacebookRestClient->friends_get()
#2 C:\<path_to_drupal>\drupal\sites\all\modules\fb\fb_views\fb_views_handler_filter_friends.inc(21): fb_get_friends('423', Object(stdClass))
#3 C:\<path_to_drupal>\drupal\sites\all\modules\views\includes\view.inc(660): fb_views_handler_filter_friends->query()
#4 C:\<path_to_drupal>\drupal\sites\all\modules\views\includes\view.inc(587): view->_build('filter')
...
I realize this bug is probably an uncommon corner case, but I think it can be fixed by updating line 449 in fb.modules to read:
try{
$fb->api_client->users_getLoggedInUser();
}
catch(Exception $e){
//TODO: this should forward to login page
return;
}
BUT I don't know how to forward the user to the fb_connect initialization page! Is there a function I can call that will get this process going? Thanks!
Comment | File | Size | Author |
---|---|---|---|
#17 | Screen shot 2011-01-03 at 9.11.16 PM.png | 231.2 KB | frdesign |
Comments
Comment #1
Dave Cohen CreditAttribution: Dave Cohen commentedAgreed there should be no error.
About forwarding the user, I'm not sure you want to forward them anywhere. Just treat them as a not logged in user. the code in fb_connect.js should reload the page, thus showing they are not logged in.
Comment #2
nighthawk117 CreditAttribution: nighthawk117 commentedNot sure I'm following you on this, are you suggesting that fb_connect.js poll Facebook and reload the page if the session disappears? I'm ok with just treating them as a logged out user, but I'm not clear on how to accomplish this. It seems like I may need to wrap every call the facebook api's with a try catch block... but even if that's the fix, what exactly would go in the catch block?
Comment #3
nighthawk117 CreditAttribution: nighthawk117 commentedActually, I think I understand what you're saying... Typically the js will reload the page immediately after page load, if the fb session has disappeared. So the appropriate action here is to simply return empty content, display it, and allow the js to reload the page to reflect that the user is no longer authenticated. Correct?
Comment #4
Dave Cohen CreditAttribution: Dave Cohen commentedIgnoring facebook connect for a moment... Say you're logged into a drupal site. You leave that page in your browser for a long time, during which the drupal cookies expire. Next time you click a link or refresh the page, you'll find yourself logged out. (But until you click, it appears like your logged in). This is common behavior on most websites, not drupal-specific.
Now, with facebook connect... Say you're logged in to faceobok and an DFF-powered site. You log out of facebook. In your other window, the DFF site does not update automatically. When you click a link or refresh a page, then you discover you are not logged in. Again, not drupal-specific, I think most if not all facebook connect sites will behave this way.
I don't think DFF needs to handle this case any differently. Do you?
Comment #5
nighthawk117 CreditAttribution: nighthawk117 commentedHm ok, so I'll just update access args for any page making calls to fb's api. For some reason I wanted more than that, but it does seem to work just fine...
Comment #6
Dave Cohen CreditAttribution: Dave Cohen commentedmarking as fixed
Comment #8
letapjar CreditAttribution: letapjar commentedI'm re-opening this issue b/c I don't think the behavior described by Dave Cohen in post #4 is really how things are currently working in DFF.
I just recently installed DFF and enabled the fb_example module since it already has the programming for adding like buttons on node page etc.
When I log in to facebook (while not logged in to my drupal site) If I then go to my facebook app - DFF logs me into the drupal site (so far so good).
However, now when I log OUT of facebook - and go to my drupal site in a separate tab - the drupal site has me still logged in even though I logged out of FB. I can browse arouns the site and it still shows my facebook username etc.
If I click logout - it still does not log me out - I still see the facebook username after logging out.
I suspect it has to do with the facebook javascript but i'm still new to this module so I haven't had time to fully understand the code.
Certainly if one logs out of facebook then the drupal site should not the person logged in.
Comment #9
JoshuaBud CreditAttribution: JoshuaBud commentedI've included a short screen cast demonstrating what happens with the site I'm working on. I am unable to log out of the drupal side period. I have successfully logged out of FB using the app within FB as demonstrated in the cast, but as you'll see it is clearly not logging me out of the Drupal site. even after I visit the website outside of FB and try to log out it's not happening.
http://screencast.com/t/1G2ixOD04H
Looking forward to hearing back on this.
BTW I'm posting this as I realize that there has been a newly updated version and will reply if things get fixed. Even after updating the issue is still present.
Comment #10
Dave Cohen CreditAttribution: Dave Cohen commentedDo either of you guys see javascript errors when clicking logout? use firebug or something like that to check.
JoshuaBud, read the doc recipe for canvas pages. make sure you've made the right changes to settings.php then sync properties on your apps. Make sure you've checked the primary checkbox for your connect app.
Comment #11
JoshuaBud CreditAttribution: JoshuaBud commentedThe following errors pop up.
The "fb-root" div has not been created. all.js line 3
all.js:6TypeError: Result of expression 'e.root' [undefined] is not an object. all.js line 6
Line 3 code
line 6
Comment #12
letapjar CreditAttribution: letapjar commentedOk - so I login to facebook - go to my site's app - which automatically logs me into the site.
Then I log out of facebook.
i go to my site's url
It shows me as logged in with my facebook username
when I click logout firebug says "fb_logout() called without a session"
Comment #13
frdesign CreditAttribution: frdesign commentedI have the same issue but it only seems to happen in Safari (I'm on a mac). I get logged off facebook itself and my app page reloads and keeps me logged in, but when I quit and reopen Safari I'm no longer logged in on my app.
On Firefox everything seems to be working perfectly. I get logged off both app and facebook whether I use the facebook logout or my app's logout.
Comment #14
Dave Cohen CreditAttribution: Dave Cohen commentedCan anyone reproduce this on www.drupalforfacebook.org or apps.facebook.com/drupalforfacebook ?
Comment #15
letapjar CreditAttribution: letapjar commentedHmm.
Seems like www.drupalfoprfacebook.org is a bit more robust. Here is what I did:
Log into facebook.
go to apps.facebook.com/drupalforfacebook -> this logs me into drupal for facebook
logout out of facebook
go to www.drupalforfacebook.org
I get the "you're connected" header along with my facebook profile pic. BUT
when I refresh the page it correctly detects that I'm logged out and show the connect with faceboopk button.
It's this last part that is not happening on my site. so maybe there is some setting or customization that I am missing?
Comment #16
Dave Cohen CreditAttribution: Dave Cohen commentedSometimes javascript errors like that are because some other module (fb_social?) is initializing facebook's javascript.
Comment #17
frdesign CreditAttribution: frdesign commentedI accessed the Facebook for Drupal page with Safari. When I logout through Facebook the app still shows me being logged in (See attached screengrab). I have to use the logout link to logout from the app.
In Firefox I get logged off both in one shot.
Comment #18
ajaykumartak CreditAttribution: ajaykumartak commentedSo Dave what should we do to get out from #15 problem. I am also facing this problem on my website.
Comment #19
Dave Cohen CreditAttribution: Dave Cohen commented@ajaykumartak, which release are you using. Some recent changes to .dev release *might* have fixed this, I'm not certain.
Comment #20
ajaykumartak CreditAttribution: ajaykumartak commented@Dave now i m using version 3.x -dev for Drupal 6.x ........ but still i m facing this problem.
Comment #21
Dave Cohen CreditAttribution: Dave Cohen commentedDoes your application prompt for the offline_access extended permission?
Comment #22
Dharmendra.s CreditAttribution: Dharmendra.s commentedI m also facing this proublem , when i m logout from our Fbconnect site i also logout from facebook.. i m using 3.1
Comment #23
Dharmendra.s CreditAttribution: Dharmendra.s commentedfb connect is working fine instead of drupal for facebook, if you want only connect to facebook ..