I have a Rails application with a user model. I want to allow users to log in with multiple services. There are two ways I can think of storing this in a database, but I'm not sure if this is the best. I should note that I would like users to be able to connect to several services and link accounts.
Method 1:
For each service, add tokens / secret fields to the User table. This seems a bit problematic, because if I want to store, for example, a twitter token, twitter-timer, Twitter screen name and img twitter profile? I could see that the User table has many unused columns. There may be additional information that I want to store with each service. It will look something like this:
id
twitter_token
twitter_screenname
twitter_secret
twitter_pic
facebook_token
facebook_secret
facebook_pic
facebook_name
google_token
google_secret
google_name
etc.
Method 2:
Or each user can have many social logins, and each social input belongs to one user. Then I would have a table that looked like
user_id
token
secret
social_type
social_pic
and a social type table will look something like this:
id
social_site_name
oauth_url
, , . , , ? , STI ... , .
!