diff --git a/src/Duende.AccessTokenManagement/ClientCredentialsTokenEndpointService.cs b/src/Duende.AccessTokenManagement/ClientCredentialsTokenEndpointService.cs index 9305719..b871bb7 100755 --- a/src/Duende.AccessTokenManagement/ClientCredentialsTokenEndpointService.cs +++ b/src/Duende.AccessTokenManagement/ClientCredentialsTokenEndpointService.cs @@ -58,21 +58,10 @@ public virtual async Task RequestToken( { var client = _options.Get(clientName); - var clientIdMissing = string.IsNullOrWhiteSpace(client.ClientId); - var tokenEndpointMissing = string.IsNullOrWhiteSpace(client.TokenEndpoint); - - // If both are missing, we infer that this client is just not set up at all - if (clientIdMissing && tokenEndpointMissing) - { - throw new InvalidOperationException($"Unknown client {clientName}"); - } - - // Otherwise, if we don't have a specific value that is required, throw an appropriate exception if (string.IsNullOrWhiteSpace(client.ClientId)) { throw new InvalidOperationException($"No ClientId configured for client {clientName}"); } - if (string.IsNullOrWhiteSpace(client.TokenEndpoint)) { throw new InvalidOperationException($"No TokenEndpoint configured for client {clientName}"); diff --git a/test/Tests/ClientTokenManagementTests.cs b/test/Tests/ClientTokenManagementTests.cs index cf5d468..53797aa 100644 --- a/test/Tests/ClientTokenManagementTests.cs +++ b/test/Tests/ClientTokenManagementTests.cs @@ -27,7 +27,7 @@ public async Task Unknown_client_should_throw_exception() var action = async () => await sut.GetAccessTokenAsync("unknown"); (await Should.ThrowAsync(action)) - .Message.ShouldBe("Unknown client unknown"); + .Message.ShouldBe("No ClientId configured for client unknown"); } [Fact]