vladimirich
vladimirich

Reputation: 67

How to store OAuth data

We have several oauth2 providers people can authorize through (twitter, facebook, etc). Now we store data in database via "provider/id". The problem is: we want a possibility to use several oauth2 providers for one user, i.e. user can authorize through facebook, then through twitter and it would be one user in our database. We thought about related table, like oauth_users_info, or something like that, where we will store fields like facebook_id, twitter_id etc, and use it after authorization. Is that a good practice or u can propose something better? I'm afraid of pitfalls that can cause some problems afterwards.

Upvotes: 0

Views: 62

Answers (1)

Raza
Raza

Reputation: 2388

Actually, you may want to create Identity model, associated to User model. User can have many Identities like facebook, twitter, etc. Your Identity model will be like,

Identity(id: integer, uid: string, provider: string, user_id: reference)

Upvotes: 1

Related Questions