I am looking to implement oAuth in my current application. What is a good database structure to store information required, such as token etc-era. Are there any standards?
Asked
Active
Viewed 2.2k times
10
-
I suppose you mean a database for an OAuth server/provider? – Simon Mourier May 10 '13 at 20:51
-
No, database structure – John May 11 '13 at 09:12
-
To do what? Do you need to store rows of token for a client application? – Simon Mourier May 11 '13 at 09:50
-
To store users via twitter, fb etc – John May 11 '13 at 12:49
4 Answers
12
I was considering the same thing. In general, I'm doing:
user_oauth_info
-------------------------------
id (int auto-inc)
user_id (int)
oauth_provider (varchar 20)
acccess_token (varchar 40)
refresh_token (varchar 40)
expiry_date (datetime)
A refresh_token is provided by SalesForce; does not expired and is used to get refreshed access_tokens. They only give you one if your callback URL is a mobile device, though, which is irritating.

Anthony
- 5,275
- 11
- 50
- 86
-
Update: There are better suggestions at http://stackoverflow.com/questions/4534337/what-is-the-recommended-database-structure-for-oauth-provider?rq=1 – Anthony May 23 '13 at 19:27
1
You could start with what VS2012 suggests for their MVC framework:
webpages_OAuthMembership
Provider nvarchar(30) (clustered primary key)
ProviderUserId nvarchar(100) (clustered primary key)
UserId int
webpages_Membership
UserId int (Primary Key)
CreateDate datetime
ConfirmationToken nvarchar(128)
IsConfirmed bit
LastPasswordFailureDate datetime
PasswordFailuresSinceLastSuccess int
Password nvarchar(128)
PasswordChangedDate datetime
PasswordSalt nvarchar(128)
PasswordVerificationToken nvarchar(128)
PasswordVerificationTokenExpirationDate datetime
Then define your own Users table, something like:
UserID int (Primary Key)
UserName nvarchar(80)
Name nvarchar(80)
Surname nvarchar(80)
I don't really have a reason for doing it this way, but I guess that the Microsoft people that came up with this schema know way more about this than I do, so I think it's great place to start.