Social Login Workflow for Mobile Apps
Most apps these days make the app signup experience smoother by giving users the option of signing in with their existing social accounts. This makes life much easier for users as they can now sign in to your app with just one-click using their existing facebook, google or twitter accounts.
But as a developer, you would probably like to store information about the users who sign in with their social accounts to your user database? How can you capture and model this information in your backend architecture?
This is a question that had me scratching my head for a while and I could not seem to find any information online on how best to implement the social login workflow for the backend of my mobile apps. After some research and chatting with other developers, here is the solution I came up with. This is a first run solution and I know I will come back and update the process and workflow as my apps continue to grow in size and complexity.
The above diagram shows the social login workflow if the user signs into your mobile app with their Facebook account.
The above diagram shows the social login workflow if the user signs into your mobile app by creating a new account.
*Note that after successfully receiving the callback from the relevant social provider or your cloud database, it is probably best to sign in the user at this stage (i.e show the user the next screen after login) and perform the rest of the workflow asynchronously in the background..ain’t nobody got time to be waiting around for that (“that” in this situation referring to updating your database of course).
On the back end of your app, this is an example of what is going on in your user database.
User Database for Mobile App
If your users decide to login with any of their social logins, you can link the user accounts as shown in the table below.
User Database for Mobile App (Social Login)
Update: I was at a dev conference recently and it seems a lot of companies are not linking user accounts in the background. So if a user signs in with facebook, later on with twitter and then creates an account, they will effectively have three separate user records in your database…*shrugs*