Implementing webservice for login with social sites

I work with websites for iOS and Android applications and have to develop a service for entering social networks.

The application must support Twitter, facebook, linkedin and google plus login.

As parameters, I accept the user ID from the social site and the site from which this ID was sent, and basic user information, such as first name, last name and email address.

Below is the structure of the corresponding tables for this

  • user table

    userid | email | deviceid | username | lastname | password

userid is basic and email is unique

  1. user social networking table

    userid | site | Marker

When I get this information from the external interface, I first check if the social user ID exists. If the social id does not match, I check if the email exists in db or not. If the email address is not in db, I register a new user.

Now the main problem is that twitter sdk for android and ios does not return email, and even facebook does not return email if the user is registered by phone, because of this I had a problem that uniquely identifies the user to my end. I searched a lot, but I can not find a solution for this.

Please correct me if I am mistaken anywhere in my approach and offer me how I can deal with the email problem.

+6
source share
3 answers

I would use 1 table for both types of users, for example:

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

'type' will list the possible types of accounts: fb , twitter , google or email

"socialid" will have an identifier from a social network (the identifier is included in the oauth response) for users coming from them, and will be null for ordinary users (registered by email)

"email" will include email for regular users and null for social users

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

+3
source

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

+2
source

Typically, the Facebook API should come with a user ID. The Twitter SDK is a bit more complicated. Try storing your Twitter username in your database.

0
source

All Articles