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
user table
userid | email | deviceid | firstname | lastname | password
userid being primary and email is unique
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.
Google Sign-in is free. No pricing.
Globally, and across all industries, Facebook is by far the most popular social login option on both desktop and mobile.
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.
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
Take a look at http://hybridauth.sourceforge.net/ and implement to suite your architecture or solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With