public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { using (UserAuthRepository _repo = new UserAuthRepository()) { var user = _repo.ValidateUser(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "Provided username and password is incorrect"); return; } var identity = new ClaimsIdentity(context.Options.AuthenticationType); //identity.AddClaim(new Claim(ClaimTypes.Role, user.UserRoles)); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); identity.AddClaim(new Claim("Email", user.Email)); identity.AddClaim(new Claim("RoleId", user.UserRoleId.ToString())); context.Validated(identity); } }