Dave,

I have smooth facebook connect login and logout using 6.3.dev of October 31.
But when I tried the latest 6.3.dev of Nov 3, I have to do a page refresh to have the username appear (logged in).

Cheers.

Files: 
CommentFileSizeAuthor
#3 fb_session_loop.diff1.42 KBDave Cohen

Comments

Dave Cohen’s picture

Issue tags:+fb3-blocker

Thanks for the report. I'm seeing this, too.

Not sure exactly what changed recently but this needs to be fixed.

Dave Cohen’s picture

Assigned:Unassigned» Dave Cohen

Looking into...

Dave Cohen’s picture

Status:Active» Needs review
StatusFileSize
new1.42 KB

Here's an update that I'm testing. I think it fixes the problem, not sure there are no ill effects...

Juan C’s picture

There you are. It fixes the problem (or even seems smoother logins/logouts). Patch #3 applied against latest 6.3.dev.

Cheers.

Dave Cohen’s picture

Status:Needs review» Fixed

Assuming no longer a problem.

robsongmoser’s picture

Version:6.x-3.x-dev» 6.x-3.0-rc1

Hello, I'm getting this issue with 6.x-3.0-rc1.

robsongmoser’s picture

Category:bug» support
Status:Fixed» Active

Hello Dave,

Thanks for the great module. I have read the Read Me to the end and think I have everything set up properly. I am getting this exact issue with 6.x-3.0-rc1. I can login to fb and it works but my page doesn't refresh automatically.

Dave Cohen’s picture

Can anyone reproduce on http://www.drupalforfacebook.org? If so, what browser?

robsongmoser’s picture

Hi Dave,

http://www.drupalforfacebook.org works fine for me with latest version of Firefox on latest OSX. I must have some glitch in my Drupal set up.

Are there any diagnostics I could try?

Dave Cohen’s picture

Use firebug or something like it to look for javascript errors.

robsongmoser’s picture

Status:Active» Closed (fixed)

Hi Dave,

I tried logging in to my site using Safari and the refresh worked. Then I tried logging in from Firefox, my usual browser, and it works, maybe a little slowly, but it does refresh by its self. Maybe I was just being impatient? Anyway, its working now.

Dave Cohen’s picture

Status:Closed (fixed)» Fixed

cool. sounds fixed.

By default what happens is 1) user connects, 2) javascript makes ajax call to Drupal server, 3) javascript reloads page. It would be nice to signal to the user they should wait, but I'm not sure how to pop up a wait icon.

groovehunter’s picture

i wonder if this is related or same as my current prob; I click on login button and my custom access-denied-page is shown again; after a while a request is done and i get the page as logged in; And again after some seconds another request which results again in access-denied.

btw it's the same on http://www.drupalforfacebook.org

Dave Cohen’s picture

Sorry I'm not understanding. How do you make the access denied page appear on drupalforfacebook.org?

gallamine’s picture

I have this issue too. I actually just posted some JS errors I was getting into this issue queue #681876: refresh after login

maestrojed’s picture

I am also having this problem.

Plus, if you have role specific content you need the page to reload after a successful login.

groovehunter’s picture

@Dave , to be more exact, i checked with firebug:
( i am logged into FB )
1. I open dffb homepage :
it loads dffb files, then from facebook.org: all.js is fine
but then loginstatus.php:
HTTP error 302 Moved Temporarily:

Das Laden des Quelltexts ist fehlgeschlagen:: http://www.facebook.com/extern/login_status.php?api_key=XXXXXXXXXXXXXXX&display=hidden&extern=2&locale=en_US&method=auth.status&next=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23cb%3Df399d3f77815558%26origin%3Dhttp%253A%252F%252Fwww.drupalforfacebook.org%252Ff3483446b1c4d9%26relation%3Dopener%26transport%3Dpostmessage%26frame%3Df1bd37ed7301a68%26result%3D%2522xxRESULTTOKENxx%2522&no_session=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23cb%3Df11b55945811aae%26origin%3Dhttp%253A%252F%252Fwww.drupalforfacebook.org%252Ff3483446b1c4d9%26relation%3Dparent%26transport%3Dpostmessage%26frame%3Df1bd37ed7301a68&no_user=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23cb%3Df1c4d4e22e0c94%26origin%3Dhttp%253A%252F%252Fwww.drupalforfacebook.org%252Ff3483446b1c4d9%26relation%3Dparent%26transport%3Dpostmessage%26frame%3Df1bd37ed7301a68&ok_session=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23cb%3Df2d8fb545df5532%26origin%3Dhttp%253A%252F%252Fwww.drupalforfacebook.org%252Ff3483446b1c4d9%26relation%3Dparent%26transport%3Dpostmessage%26frame%3Df1bd37ed7301a68&sdk=joey&session_version=3

Same on my two sites.

Not sure if this fits into this issue queue... I use dev version from 11-24

thx a lot much for support and your good work on the module.
florian

Dave Cohen’s picture

Sounds like a problem on facebook's end.

maestrojed’s picture

Status:Fixed» Active

In Summary the issue is that after a successful authentication from Facebook the drupal page and the Facebook Connect button do not reload or change to represent that the user is logged in. If you refresh the drupal page this change is reflected. The page should refresh on its own. Or at least be an option.

This issue seems to arise when you use the "User Management" portion of the module and allow form alters.

If you use the Facebook Connect login Block it seems to work a little better. I got mixed results of it changing the button after login. Regardless it still does not reload the page.

Reloading the page is important because many drupal sites and pages will have different content or functionality based on a user's role. For instance on my site the main functionality is adding content. However only authenticated users can add content or see the add content form. If the page does not reload the Facebook authenticated user never sees the "add content" forms.

The patch above may be for a different version. The patch does not apply and a manual inspection of the patch reveals that the current 6.x-3.0-rc1 is different then expected. I imagine that patch is no longer useful which is why the status was changed to active and not needs work.

Dave Cohen’s picture

Issue tags:-fb3-blocker

In my tests, both on my dev env and drupalforfacebook.org, the pages reload just as they are supposed to.

Comment #17 makes me think there was a temporary problem on facebook.

Not much I can do unless someone provides details how to reproduce this.

maestrojed’s picture

You are correct. I created a simple install and it worked great. I guess my issues is a conflict with another module or something on my site. Sucks. Any debug suggestions? I ran a javascript profile and I didn't see any errors. There was a bunch of stuff.

Should I change the status of this issue to closed(cannot reproduce)?

Dave Cohen’s picture

Status:Active» Fixed

Marking as fixed (which it was before #19).

If you figure it out, please let us know what causes this.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

US Drupal Development’s picture

Version:6.x-3.0-rc1» 6.x-3.0-rc7
Status:Closed (fixed)» Needs work

Yeah, I'm seeing the same thing. Fresh install of rc7. User connects, and then the site just hangs.. no refresh at all. Have to 'hard refresh' to see the Fb info pop up. This also therefore breaks any custom redirects. Switched to Garland theme and see the same issue.

orangeudav’s picture

I have same problem as #24 after logout and relogin with fConnect button in the login block. Page is not refreshed.
I am created hook_fb($op, $data, &$return) and logging $op and $data, i see nothing event after relogin.

Chrome (and Chromium), "Set FB Cookie" enabled

Dave Cohen’s picture

Do you guys see any errors in firebug or chrome console when reproducing this?

orangeudav’s picture

Chromium

while open facebook auth dialog this error was 134 times:

(134) Unsafe JavaScript attempt to access frame with URL https://www.facebook.com/login.php?api_key=190101651017102&skip_api_logi... from frame with URL http://xxxxxxxx.ru/. Domains, protocols and ports must match.

after close facebook auth no redirect and this error 2 times:

(2) Unsafe JavaScript attempt to access frame with URL http://static.ak.fbcdn.net/connect/xd_proxy.php#cb=f19f8f3934&origin=htt... from frame with URL http://xxxxxxxx.ru/. Domains, protocols and ports must match.

after click fConnect button again i see "An error occured" in fb auth window and after close:

(2) Unsafe JavaScript attempt to access frame with URL http://static.ak.fbcdn.net/connect/xd_proxy.php#cb=f3375d0db8&origin=htt... from frame with URL http://xxxxxxxx.ru/. Domains, protocols and ports must match.

US Drupal Development’s picture

I'm seeing this as well... /fb/ajax/session_change 302 Moved Temporarily
No refresh, nothing. Have to hard refresh to login, which makes the site very unusable.

I've tried rc7, 6, 5...

US Drupal Development’s picture

Priority:Major» Normal

If I hit the post authorize link directly:
....com/fb_app/event/[app_name]/post_authorize/

I get:
Fatal error: Call to undefined function fb_connect_init_js() in /....httpdocs/sites/all/modules/fb/contrib/fb_permission.module on line 245

Is this why it doesn't refresh?

US Drupal Development’s picture

Priority:Normal» Major

Bumping this up after more investigating...

This is now taking place on 12 websites where we use this module. It is:

* Independent, we think, of the version of Drupal for Facebook (we tried rc1, rc7, rc6, rc5, at least)
* Independent of the theme used (that is, we switched back to stock Garland, making sure to add in the FBML)
* Independent of the Drupal version (that is, we tried 6.20, 6.19, 6.18)
* Independent of the couple version of jQuery we tried (that is, we tried stock jQuery and jquery-update 2.0-alpha)
* Independent of the browser we tested (it broke in Safari, Firefox, and Chrome)
* Independent, we think, of the Fb user itself (that is, it affected all users that we tested)

It seems as though Drupal for Facebook is never "receiving" the page redirect, and thus not acting on it. The result is that the user thinks he or she is not logged in, and has to do a hard refresh. This also means if you're intending for a user to go to a new destination after login, you're out of luck.

US Drupal Development’s picture

i should have also noted...

This wasn't just an issue where we upgraded to rc7. We have older sites that stayed on rc1 that worked perfectly - and are now not working. This would seem to point to, perhaps, a change on Facebook's side that the module isn't able to handle or account for? Shot in the dark...

Dave Cohen’s picture

Priority:Normal» Major

I'm puzzled by this. I was able to reproduce just now on one of my devel sites. And I see some page not found errors in my log. looking into it.

US Drupal Development’s picture

Thanks Dave! Let us know if we can help. We've had some developers look into it but we just can't seem to trace it down. It seems like Facebook is sending back the redirect URL, but there's nothing there server-side to receive that message and act on it.

Dave Cohen’s picture

There are two ways to setup a facebook connect site...

The simplest is to have just one facebook application. On Drupal, check the "primary" checkbox. And this ensures that facebook API (javascript and PHP) are initialized on every page.

The second is to not check the primary checkbox, but instead enable the facebook block. This way, facebook's api will initialize only on pages with the block. This allows a site to have two (or more) different apps for facebook connect.

The second way is trickier. I was able to reproduce this problem using the second approach, but not the first.

So I ask the people on this thread, which technique are you using? If you have the primary checkbox enabled and still have this problem, please go to your remote app settings, click the advanced tab and list here which "migrations" you have enabled.

Dave Cohen’s picture

Also, do you have other fb modules enabled like fbconnect or fb_social? Anything non modules/fb that might initialize facebook's javascript?

Dave Cohen’s picture

#1034222: load facebook javascript asynchronously patch #3 might solve this problem. I can't reproduce it except in the case I described (#34), so I'm not sure.
If anyone is able to test that, please let me know what happens.

US Drupal Development’s picture

We only use your module - no other modules. We also were able to reproduce this with stock Drupal --- no other modules installed.

US Drupal Development’s picture

And I will test that patch now.

US Drupal Development’s picture

I upgraded to -dev and then applied the patch. Notta. A hard refresh is still required to be logged in.

What's strange is that if I head to /logout, it does the proper redirect to also log me out of Facebook, then hits my front_page, and then CORRECTLY refreshes. I see the ?_fb_js_fbu=494294092142 change to ?_fb_js_fbu=0.

So it seems like logging out refreshes properly... but logging in does not.

US Drupal Development’s picture

And I'm still seeing...

Fatal error: Call to undefined function fb_connect_init_js() in /var/..../sites/all/modules/fb/contrib/fb_permission.module on line 245

When I visit...
http:/....fb_app/event/app_name/post_authorize/

Looks like fb_connect_init_js() is actually a private function in fb_connect. Who knows if that's related.. just noticing it.

Dave Cohen’s picture

Hmmm... that fb_permission problem, I guess I overlooked it when you first mentioned it. While I don't think that is the problem, might be worth disabling that module and seeing if the problem goes away.

I think the entire fb_permssion_fb() function is no longer needed.

US Drupal Development’s picture

While that did resolve the error, it didn't fix the problem. But I did some more digging... I firebug'd logging out and back in.

I notice two strange things:
A POST to /fb/ajax/session_change that resolves in a 302 Temporarily Moved warning.
A GET to the correct redirect address, which does load 200 OK, but of course I never get there (unless I hard refresh)!

It's like it's only a step away from working... but we don't quite get there.

Dave Cohen’s picture

Maybe something is calling drupal_goto() from within the fb/ajax callback.

Try adding something like this to the top of drupal_goto()...

<?php
watchdog
('DEBUG', "Something called drupal_goto()! " . dprint_r(debug_backtrace(), 1));
?>

Then, reproduce the error. Look in the log for that message, when /fb/ajax/session_change was called. Post the stack trace here.

Dave Cohen’s picture

Oh, and if you have global redirect enabled, try disabling it.

US Drupal Development’s picture

Finally, some progress. The backtrace revealed we still had a _user hook floating around somewhere in a module. When we removed this hook, bam. Refresh. We are investigating other websites to see if that is the commonality. (Though, we WERE able to replicate this issue with a stock D6 install.) What is the "correct" way to set a custom redirect after fb logs in?

US Drupal Development’s picture

A thought... Is it possible this issue originated from a conflict (a user hook, or in other people's examples, global_redirect) -- but then extended to other sites because of some... SESSION variable or something? Just another shot in the dark.

Dave Cohen’s picture

Status:Needs work» Fixed

What is the "correct" way to set a custom redirect after fb logs in?

http://drupal.org/node/969242

The way it works is, javascript detects the session change, then posts AJAX request to drupal, basically asking "what should I do now?". When the ajax returns, fb.js will reload the page, unless the ajax returned some other instruction. If instead of returning the ajax fails or redirects or what have you... no redirect. The goal is support advanced cases where instead of redirecting, just a portion of the page is updated, as well as the blunter instrument which is refreshing the entire page.

If you can reproduce with stock D6, let me know. Otherwise, OK to mark this as fixed again?

rmarino’s picture

Status:Fixed» Active

Sorry to reopen this, but I have this same problem and as much as I read all the thread still cannot make it work. Don't know how it is fixed.
I need to hit the refresh button to see the username.

I also tried to create a rule, when users login with facebook then redirect but it doesn't fire.

@US Drupal Devel said "The backtrace revealed we still had a _user hook floating around somewhere in a module. When we removed this hook, bam", does this mean I can't use hook_user() at all for this to work? I have to use it.

My site is on development ( a bit messy at this point) but you can check if you want: http://nytlights.vl64.dinaserver.com . As you can see, when you connect, until you refresh the browser, username doesn't change.

I'm using last 6.x-3.x-dev (25 jan), there is just 1 app and primary is checked. Deactivated global redirect.

Dave Cohen’s picture

Status:Active» Postponed (maintainer needs more info)

do you see any errors in either firebug or your server log?

rmarino’s picture

No errors.
Well, what I did now is to change the Post-Authorise Callback URL to: http://nylights.com/user
Firebug shows me:
POST http://nytlights.com/fb/ajax/session/change and the response is the http://nylights.com/user html.

After that:
Cookie changed SESSxxxx
GET http://nytlights.com/user -> this one doesn't have response

But the page doesn't change at all.

Any ideas?

Thanks

Dave Cohen’s picture

Any ideas?

First, change the post authorize callback back to what it was.

If you have a hook_user() that is calling drupal_goto() or anything calling drupal_goto() during the ajax callback, then you have the same problem as the earlier poster. Try putting a breakpoint in fb.js around line 201 (the jQuery.post callback). See if that breakpoint is ever reached.

rrrob’s picture

I'm having the same issue. I set breakpoints on line 195 if (Drupal.settings.fb.controls)... and on line 202 if (js_array.length > 0) {... and line 195 is hit, but not 202.

It is on the homepage of http://www.teamelites.com/ if you are interested.

This has got to be something that Facebook changed on their end. FB connect was working just fine a few weeks ago when I last tested, and I haven't changed anything on the site.

Dave Cohen’s picture

deckerdev, that makes it sound like the ajax call to drupal is being made, but not returning successfully. Any errors in the drupal log?

Anyone out there with jquery chops? How can I call FB_JS.reload() when the jquery.post() fails?

rrrob’s picture

Unfortunately, I'm not seeing any errors in the Drupal log.

As for jQuery.post(), you may want to look at jQuery.ajax() instead. It provides an error handler that the shorthand jQuery.post() does not. See http://api.jquery.com/jQuery.ajax/

rrrob’s picture

Something like this should work:

jQuery.ajax({
  url: Drupal.settings.fb.ajax_event_url + '/' + event_type,
  data: data,
  success: function(js_array, textStatus, XMLHttpRequest) {
    //debugger; // debug
    if (js_array.length > 0) {
      for (var i = 0; i < js_array.length; i++) {
        eval(js_array[i]);
      }
    }
    else {
      if (event_type == 'session_change') {
        // No instructions from ajax, reload entire page.
        FB_JS.reload();
      }
    }
  },
  error: function(XMLHttpRequest, textStatus, errorThrown){
    FB_JS.reload();
  },
  dataType: 'json'
});
rrrob’s picture

The code that I just posted will perform the page reload, but it won't use the Drupal.settings.fb.reload_url that is passed in the FB Connect button:
<a onclick="Drupal.settings.fb.reload_url='http://www.mysite.com/redirect-to-me';FB.login(function(response) {}, {perms:Drupal.settings.fb.perms}); return false;" class="fbconnect" href="#">Login</a>

When I put a breakpoint in the success callback function, the js_array variable is empty.

Dave Cohen’s picture

I'm interested to hear what is passed into that error function. That should be a clue as to why there is a problem in the first place.

funkym’s picture

I'm getting a similar bug with 6.x-3.0-rc13.

If the Firebug console is open I see the following error:
resolveRelation(params.relation) is null
resolveRelation(params.relation).postMessage(fragment, params.origin); Line 93

wanderingstan’s picture

I'm getting this same error.

Chrome reports as what seems to be an xss javascript error, or a problem with accessing an HTTPS url:

all.js:17 Unsafe JavaScript attempt to access frame with URL https://s-static.ak.fbcdn.net/connect/xd_proxy.php?version=3#cb=f310aeae7c&origin=http%3A%2F%2Farchive.scanwithstan.com%2Ff3630caeac&relation=opener&transport=postmessage&frame=f30c288e5c&access_token=AAADvbiubbyMBABNXETwSWKhVXirXZALibhvRO8LSnO4muZCgXqa1TGugwY5ZBJuDBso7AxKAE9KYDxOy6ZBHYJjGrgHlCnIZD&expires_in=0&signed_request=yuiM0YqcfQRy1G4QU4SfVnRAXuzuWsPUi0qRGMga8G0.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiJBUURWS1BDRGdsNlV3NHBISWRqa0xWd3h1U2daY0JWMl9yeHNlQ2xIdDVNcTgtb0Vnai1nSFhnb2FtOFRFbkFERGFreDdxejBpc2h5c0hEcjNhZFZjM2VvNDl3Q2FnbGxKNkI2V0Vsa0dRUjhwcDJXUWxiN3E5WXRBRnMxU1FxbUM4ZHZ5bzVPaW8wTlRPSm9uYnJjbURKWHUyVVRlVVdRd0hpTVpIS0dkVGgzRTlKUTBRNWtTRFYxdE1FY2JPQU1kNkUiLCJpc3N1ZWRfYXQiOjEzMjk0MzgxNzEsInVzZXJfaWQiOiIyNTI4MDAwMDEifQ&base_domain=archive.scanwithstan.com from frame with URL http://archive.scanwithstan.com/.
Domains, protocols and ports must match.

Uncaught TypeError: Object #<Object> has no method 'getSession'
all.js:31 XFBML tags failed to render in 30000ms.

A similar problem occurs when attempting to log out.
Uncaught TypeError: Object #<Object> has no method 'getSession'

eliosh’s picture

Version:6.x-3.0-rc7» 6.x-3.2-rc3

Can confirm error in #59 with version 6.x-3.2-rc3

Dave Cohen’s picture

Status:Postponed (maintainer needs more info)» Fixed

I'm getting this same error.

Same as what? Don't completely change an ancient thread. Marking fixed (cause I think the original issue is)

ShaneOnABike’s picture

Version:6.x-3.2-rc3» 6.x-3.x-dev

I can confirm this is working (wasn't before) on our development site with the latest dev version.

@Dave Cohen: I changed the version to dev since it wasn't working in RC3 but rather dev (I hope that's ok).

Just wondering if you could release another version RC4 or an official release since not having this work pretty much makes it hard for users to know that the module is functioning :/

Any way just my $0.02. Thanks for a great module with lots of features and API's!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.