Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement webservice for login with social sites

I am working with the webservies for ios and android app and need to develop a service for login with social media.

The app need to support login with twitter, facebook, linkedin, and google plus.

As parameters, I am accepting userid from social site and the site from which this id originated and the basic user info like firstname, lastname, and email.

Below is the structure of relevant tables for this

  1. user table

    userid | email | deviceid | firstname | lastname | password

userid being primary and email is unique

  1. user social media table

    userid | site | token

When I get this information from the frontend, I first check if social user id is already there. If social id doesn't match then I check if email exists in db or not. If email is not in the db, then I register the new user.

Now the main issue is that the twitter sdk for android and ios does not return the email and even facebook does not return the email if the user is registered by phone, because of this I am having a problem uniquely identifying the user on my end. I have searched a lot but can't come up with any solution for this.

Please correct me if I am wrong anywhere in my approach and suggest to me how can I handle the email issue.

like image 705
alwaysLearn Avatar asked Nov 17 '15 15:11

alwaysLearn


People also ask

Is Google social login free?

Google Sign-in is free. No pricing.

Which social login is most popular?

Globally, and across all industries, Facebook is by far the most popular social login option on both desktop and mobile.

What is a social login email?

Social login is a single sign-on (SSO) technology that allows users to authenticate themselves on various applications and sites by connecting through a social media site rather than typing a separate ID and password on each website.


2 Answers

I'd have used 1 table for both types of users instead, like this:

userid | type | email | socialid | deviceid | firstname | lastname | password | token

'type' column would be an enum of possible account types: fb, twitter, google or email

'socialid' would have an id from social network (the id is included in oauth response) for users coming from those and will be null for normal users(registered via email)

'email' would include an email for normal users and be null for social users

Then it's just a matter of SELECT query to understand what type of user you're working with

like image 114
Eugene Sue Avatar answered Oct 01 '22 23:10

Eugene Sue


Take a look at http://hybridauth.sourceforge.net/ and implement to suite your architecture or solution.

like image 40
Kolawole Gabriel Avatar answered Oct 02 '22 00:10

Kolawole Gabriel