I've been trying to use the code mentioned here:
https://stackoverflow.com/a/35882775/7440281
...as a way of solving my own problems. Basically all I want to do - initially anyway - is call a function of some sort and provide it with a user name and password. The validation would be done externally but has been added to my instance of ResourceOwnerPasswordValidator. Note that the interface seems to have changed between when that was written and the present day. All I'm doing as a very first step is checking for a particular name too to try and keep things simple to start with. This is the current content of my class:
public class ResourceOwnerPasswordValidator : IResourceOwnerPasswordValidator
{
public Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
{
if (context.UserName == "PatrickS")
{
var result = new GrantValidationResult("PatrickS", "password");
}
else
{
var result = new GrantValidationResult(TokenRequestErrors.UnauthorizedClient, "Username Or Password Incorrect");
}
return Task.FromResult(result);
}
}
I have both the interfaces mentioned in the comment defined in the comment. I have referred to them in ConfigureServices using services.AddTransient() too. The problem is that all I currently get is 'unauthorised_client'.
This may or may not be down to the configuration of the Client. This is from the settings of the client in question:
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
RedirectUris = { "http://localhost:5002/signin-oidc" },
PostLogoutRedirectUris = { "http://localhost:5002" },
The RedirectUris was previously set as part of one the quickstart tutorials. I'm guessing this should be changed to something else but it's not clear what this should be. I'm also not clear whether the AllowedGrantTypes has been correctly set. There may be other things of course but I'm still new to Identityserver.