Database table structure for storing SSO information for FB or Google+

facebook-graph-api, google-oauth, oauth, single-sign-on

Solution

For SSO login definitely you need to have your user_id and some basic details which allow you to connect to FB or google

- provider: "it will be either FB or Google or anything in future"

- token: "This token we receive from FB and Google. In case of FB it expires after 3 months or so where as it does not expire for google as per my knowledge"

- token_expired:" As In FB token expires after a time so you can have this flag in place if you need to refresh it after that duration"

- user_id: "This is your User id:

- uniqueid: "This is the Unique ID which you will get from FB and Google. That helps to identify your user in FB/Google"

These are the minimum fields you can add and these will even help you to scale your app. In the sense if you want to pull or push data from google and FB at that time Access_token and unique_id will help you.

Also incase you want to see some publish source then you can see some of the code on github e.g. django-social-auth

For some details you can refer google documentation and Google OAuth2

Hope this will help.

Problem

I have a web application that I would like to add single sign on capability using user's Facebook or Google+/Google App account. I have a `USERS` table that stores users login information. All users are required to have a record in this table no matter if they signed up using FB or Google+. I am trying to figure out the information that I need to store in the database in order to link `USERS` table records to FB or Google information. Facebook documentation states: the app should store the token in a database along with the `user_id` to identify it. So should I create a table called `SSO_LOOKUP` with following columns: - USER_ID // user's id that links to my `USER` table - PROVIDER_ID // user's FB or Google account id - PROVIDER_TYPE // indicates if it is Google, FB, Twitter, etc. - ACCESS_TOKEN

Original source