What I want to do is:

I have an existing Drupal user. They are not logged in. They come to the site and click the "Connect with Facebook" button. As soon as they authorize the app, I want to look up their Drupal user by email from Fb and authenticate them as that user so that their Fb and Drupal accounts are linked.

Register Users seems to do this during cron, or user edits, but I'm trying to figure out how to log them into Drupal with their existing account as soon as they click the Connect button.

This page http://wiki.developers.facebook.com/index.php/Communicating_with_Users_v... tells me how to get the user's email from FB, but I'm not sure how to integrate such a thing into Connect.

Can somebody point me in the right direction? I think I'll need to write a contrib module for it, which is fine, but I don't want to reinvent the wheel more than I need to. Seems like a lot of the heavy lifting is already done with the User Management, and Register User modules so I'd like to integrate with them as much as possible.

Thanks for your help! And Dave thanks for a great module!

Comments

Dave Cohen’s picture

Register users does this.

During cron, it sends facebook a hash of all your users. Facebook has to have this information ahead of time.

When the user registers, facebook lets the module know that it has already seen that email address, then the appropriate authmap entry is made.

kubajs’s picture

Version: 6.x-2.0-beta10 » 6.x-3.x-dev

Hi Dave,
first of all - thanks for great module and all your work

but unfortunatelly - above mentioned cron procedure does not work for me.
in logs I can see lot of "application_name failed to register email hash..." - do you have any suggestion what should be wrong, where should I look?
when I have a look at /admin/build/fb/app/application_name/fb_register - there is "61 of 353 accounts have been registered for application_name"

Another question - is it possible to make the FB connect button added to Login form to behave the same way as the button "Facebook Connect Login" block?

Dave Cohen’s picture

I can't tell if that's an intermittent failure or a permanent one. Might just be a user whose email address is not known to facebook. I'm not sure there's a problem.

The place to look is fb_register.module.

thedavidmeister’s picture

Category: support » feature
Status: Active » Needs review

This fb->local user mapping now happens upon user registration, right? So this support request is a feature request that was actually implemented at some point?

Dave Cohen’s picture

Status: Needs review » Fixed

this issue dates back to a time when things were done much differently than they are today. The whole hashing thing that facebook used to require is no more.

Now there is a simple setting in fb_user.module. It will map users if they are logged into drupal and connected to facebook, or it will map users when their email addresses match exactly. That's it.

Status: Fixed » Closed (fixed)

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