How does social oauth really works?

304 Views Asked by At

I am confused with how social oauth works? Lets say i have implemented social oauth login in my project.

user A signed up in my website with Google Oauth. I somehow put that SIGN UP WITH GOOGLE button in my sign up page and then user will click it and will be directed to a link where google will ask to authorize my app or not. If the user A allows, then at first time what information does the google server send to my server. It will send something so that i could save it in my server to know that a user A has been signed up and could give the userA a id to link it to other tables of my database which is in my server (nothing to do with google server). So real question is what will google(or any other service provider like facebook, twitter etc) send me when a new user signed up and when a existing user signed in again. what will happen if a user (already signed up) try to sign up again? or didn't authorize the website again when logging in?

If you want more detailed question, please comment and I will elaborate.

2

There are 2 best solutions below

3
Linda Lawton - DaImTo On

Ok first off lets use a different term than social login. Lets call it third party login and heres why.

Your application has its own login system users can create their accounts on your system by say adding an email address and creating a login name and a password. Now you want to add third party login that being, Facebook, google and twitter login. These are actually third party logins.

What you will actually be doing is linking the users third party social media accounts with your login system. The term often used for this is called account linking.

Lets say user A has created an account in your system already now A has a Facebook account so they would like to link their Facebook account with your login system. So you create a Facebook login button Facebook will return to you an id this often being the id of the user on facebooks system. So when the user logs in using Facebook you get the Facebook id back that you can store on the users account in your system.

Things get a little more confusing if user B wants to login to your system using Google and B does not already have an account in your system when they login then you will probably get the users id and i think you get their email address back as well so you can use the email address from google so you can create them a actual account on your system and directly link the google login to it automatically.

Its been a while since i have done it but i believe that you get the user id and the email returned to you from third party providers you may want to check thought if memory serves they are not all the same and you may have to make a request to get the email address after you get the id back.

0
Guenole de Cadoudal On

Social login is still not normalized. You have to work them out one by one unless you leverage something that do it for you like the trusstee.io solution. It appears to be simple to use and is described here https://medium.com/me/stats/post/ef5d5a5a3943.