Skip to content
Discussion options

You must be logged in to vote

Good catch! You can add the necessary services to ASP.NET Core's service provider by calling AddClientCredentialsTokenManagement(). One or more named client definitions need to be registered by calling AddClient().

// Program.cs
builder.Services.AddClientCredentialsTokenManagement()
    .AddClient("client", client =>
    {
        client.TokenEndpoint = "https://demo.duendesoftware.com/connect/token";
        
        client.ClientId = "m2m";
        client.ClientSecret = "secret";
        client.Scope = "api";
    });

You can then register named HTTP clients with IHttpClientFactory. These named clients will automatically use the above client definitions to request and use access tokens.

/…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SanzSeraph
Comment options

Answer selected by maartenba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants