OAuth 2.0 Database Structure

I want to implement oAuth in my current application. What is a good database structure for storing the necessary information, for example, token, etc. Are there any standards?

+7
source share
4 answers

I was thinking the same thing. In general, I do:

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) 

Refresh_token is provided by SalesForce; has not expired and is used to get updated access_tokens. They only give you one if your return URL is a mobile device, although this is annoying.

+9
source

You can start with what VS2012 offers for its 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, for example:

 UserID int (Primary Key) UserName nvarchar(80) Name nvarchar(80) Surname nvarchar(80) 

I have no reason to do it this way, but I think the Microsoft people who came up with this scheme know more about this than I do, so I think this is a great place to start.

+1
source
-1
source

I think google oAuth guide will help you help

https://developers.google.com/accounts/docs/OAuth2

-2
source

All Articles