public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) { context.Validated(); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); identity.AddClaim(new Claim(ClaimTypes.Role, "user")); context.Validated(identity); }In this example, the GrantResourceOwnerCredentials method is overridden to grant resource owner credentials using the OAuthGrantResourceOwnerCredentialsContext. An identity is created and claims are added to it. The context is then validated using the Validated method, passing the identity as an argument. Overall, the OAuthGrantResourceOwnerCredentialsContext class is a useful tool for defining contexts for granting resource owner credentials in OAuth authentication.