im trying to implement a login with facebook/twitter functionality in my app, i read some guides on oAuth, and i think i understood some of the basic concept, and here is what i understood (please correct me if i’m wrong):
- myApp send request to the oAuth provider, get the (A)request token.
- send user to authenticate the (A), returns with (B)authenticated request token (is this whats called oAuth token?)
- use the (B) to get the (C)access token.
- use C to access user information.
and here is what i can’t get around my head, which one of these that i should use/store to identify the user? i thought about the possibility of using each one of those, but im always stuck on how to check if the user has signed in before…
If all you need is just authentication, then storing only
user_idis enough.So create another table like:
where
service_nameis eithertwitterorfacebook,user_id– is user’s id from twitter/facebook andmy_user_idis auser_idin your authentication system.So:
would return you your system user_id or nothing
PS:
service_namecould (and should) be normalized, I kept it as a string just to simplify an examplePPS: as you said in comments you probably would want “posting/tweeting”.
In that case you need to store user’s access token for twitter, and store nothing additional for facebook, but request for
publish_streampermission when authenticate user.