Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Login within Mobile App

I am planning to integrate "Login With Facebook" feature into my iPhone/Android App; and I have a PHP back-end for maintaining user details.

I am confused as to what is the standard way in which this feature should be implemented?

Is it that - After the user gets successfully authenticated by Facebook, should I fetch his/her details and ask him for a password to register him to my back-end or is there something else which needs to be done & I am not aware.

Please suggest the standard way of implementing this feature.

Thanks.

like image 950
Mahendra Liya Avatar asked Feb 11 '12 15:02

Mahendra Liya


2 Answers

We had the same situation..

So what I did was:

  1. Authenticate the user.
  2. Always Fetch the user's info (like name, email, dob etc.)
  3. Now send the fb id and email to your server.
  4. Server will look up the database to check the existence of fb id and name
  5. If exist, it indicates that it is a register user. (so you will let the user login in to your app)
  6. If doesn't exist, it indicates that it is a new user. (so you will take the user to
  7. Join/signup screen and fill the form with the data you got at step 2) Just leave the password field empty to let the user choose their password.
  8. Now send all details with fb id to your server and after successful response let the user login immediately because you don't need to ask the user to open email for activation link.
like image 130
Adil Soomro Avatar answered Nov 18 '22 00:11

Adil Soomro


Login with facebook button

  1. Redirect a new user to facebook for required permissions

  2. Prefill your register form with details from facebook and a password for your site.

  3. Save details of the user in your backend.

When the connected user logins again

  1. Check for active facebook session

  2. Get the userID of current facebook user is equal to that saved in your database log him in

  3. else show registration form.

like image 42
Ajeet Sinha Avatar answered Nov 18 '22 02:11

Ajeet Sinha