Closed (fixed)
Project:
Drupal for Facebook
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Mar 2012 at 12:35 UTC
Updated:
15 Nov 2012 at 22:47 UTC
I need to login mobile user. I'm getting the access_token from the app. What are the next steps to create local user (if needed) and then login him?
Comments
Comment #1
eugen80 commentedComment #2
Dave Cohen commentedThis documentation should help: http://drupal.org/node/932690
Comment #4
eugen80 commentedI've checked the documentation, there are no API examples how to link facebook account with drupal account
Comment #5
eugen80 commentedonce again, the problem:
There is iphone app (frontend) and drupal (backend) with services module. User want to login using Facebook. So,
drupal will get access_token from the mobile app. I need to proccess it and do some tasks:
- get user data from facebook
- create local drupal account if needed
- login user using drupal account
The question is, how "Drupal for Facebook" can assist me with these tasks?
Comment #6
eugen80 commentedat least it would be helpful to know which functions may help me
Comment #7
Dave Cohen commentedIf the pages we've already linked to (i.e. http://drupal.org/node/933772) don't help you, try looking at fb_user.module and maybe fb_example.module for examples of what to do.
It sounds like you're using drupal as a service, not a web site. So I doubt all the normal facebook cookies and so on will be present. You might end up explicitly passing the access token to drupal, then using fb_graph(), taking care to always pass in an appropriate token.
Comment #8
eugen80 commentedThank you, this problem is solved.. Another problem is: how can logged in user (signed in using FB) change it's profile data, I'm checking the password before changing any profile data. Bun noone knows password for a user signed in using facebook. Password was hashed on creation and saved into the DB.
Is it security issue, if I would NOT use user_check_password if user wants to update it's profile and the user was created using FB?
Comment #9
Dave Cohen commentedAnother problem needs to be in another thread. It's hard enough to maintain this issue queue as it is.
Unclear from the description above whether you're doing something special (user_check_password) or whether that is D7 default behavior. Please specify when you submit another issue.
Comment #11
mottolini commentedI have the same problem. I found a solution hacking the function _fb_user_process_authorized_user in fb_user.module.
_fb_user_process_authorized_user calls (not directly) the function getUser() in the facebook php api. getUser doesn't seem to be able to recognize a facebook user if the call comes from a web service instead of a traditional web page load.
So, what I did is to copy _fb_user_process_authorized_user in my module and have my web service receive a facebook user id from my mobile app. The workflow for my mobile app is:
here is my web service function (fragment - based on 6.x-3.1):
I don't like this approach because I would prefer to rely on well tested APIs rather than create a new version that will fail sooner or later and because maybe I expose my app/site to some security problem.
I would prefer to send, along my web service call, some facebook cookie to let _fb_user_process_authorized_user works as it should.
Any hint is appreciated.
Comment #12
Gregg Duncan commentedEugen80, Could you please post how you solved this issue. There are others of us that are trying to figure this out as well.
It seems to me that in this point the evolution of websites and mobile apps that this should be a standard practice by now.
Cordova has created the cordova facebook plugin to work with the facebook js sdk. I can login to facebook. But I have no way of logging that user into drupal and connecting the facebook user to the drupal user.
Services should be core to drupal. And the ability to do a facebook login should be a standard built into Services.
Thanks,