'How to use ResourceOwnerPassword flow when using AddAccessTokenManagerment?

I am setting up auto access token management like this:

        services.AddAccessTokenManagement(options =>
        {
            options.Client.Clients.Add("identityserver", new ClientCredentialsTokenRequest
            {
                Address = $"{idso.IdServerUrl}/connect/token",
                ClientId = idso.ClientId,
                ClientSecret = idso.ClientSecret,
                Scope = idso.Scopes
            });
        });

But I need to use the ResourceOwnerPassword type of request, which manually would be something like;

var client = new TokenClient(
_identityEndpoints.TokenEndpoint,
"client", "secret", AuthenticationStyle.PostValues);

var response = await client.RequestResourceOwnerPasswordAsync(user, pass, "scope");
var token = response.AccessToken;

How can I do this with AddAccessTokenManagement?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source