public void AddAuthorizationGrant(AuthorizationGrant grant) { Models.AuthorizationGrant authorizationGrant = new Models.AuthorizationGrant() { ClientId = Convert.ToInt32(grant.Client.ClientId), ExpiresIn = grant.ExpiresIn, IssuedOn = grant.IssuedOn, Scope = grant.Scope, Code = grant.Code, IsApproved = grant.IsApproved, IsUsed = grant.IsUsed, ResourceOwnerId = grant.ResourceOwnerId, }; using (Models.OAuthWebAPIContext context = new Models.OAuthWebAPIContext()) { context.AuthorizationGrants.Add(authorizationGrant); context.SaveChanges(); } }
public void AddAccessToken(AccessToken token) { Models.AccessToken accessToken = new Models.AccessToken() { ClientId = Convert.ToInt32(token.Client.ClientId), ExpiresIn = token.ExpiresIn, IssuedOn = token.IssuedOn, RefreshToken = token.RefreshToken, Scope = string.Join(" ", token.Scope), Token = token.Token, TokenType = token.TokenType, AuthorizationGrantCode = token.Grant.Code, }; using (Models.OAuthWebAPIContext context = new Models.OAuthWebAPIContext()) { context.AccessTokens.Add(accessToken); context.SaveChanges(); } }