IdentityServer4.Net核心3令牌响应Json为空

IdentityServer4.Net核心3令牌响应Json为空,identityserver4,.net-core-3.0,Identityserver4,.net Core 3.0,我有这个密码 class Program { static async Task Main(string[] args) { HttpClient Client = new HttpClient(); var disco = await Client.GetDiscoveryDocumentAsync("https://intranet.mycompany.com/"); if (disco.IsError) {

我有这个密码

class Program
{
    static async Task Main(string[] args)
    {
        HttpClient Client = new HttpClient();

        var disco = await Client.GetDiscoveryDocumentAsync("https://intranet.mycompany.com/");

        if (disco.IsError)
        {
             Console.WriteLine(disco.Error);
            return;
        }

        // request token
        var tokenResponse = await Client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
        {
            Address = disco.TokenEndpoint,
            ClientId = "Console",
            ClientSecret = "secret",
            Scope = "dev_api",
        });

        if (tokenResponse.IsError)
        {
            Console.WriteLine(tokenResponse.Error);
            return;
        }

        Console.WriteLine(tokenResponse.Json);
        Console.WriteLine("\n\n");
    }
}
我们只需在etc/host上设置intranet.mycompany.com以提供本地ip地址,并设置自签名证书。GetDiscoveryDocumentAsync工作正常,它连接到IdentityServer,但RequestClientCredentialsTokenAsync返回错误的请求

{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{ 缓存控制:没有缓存 Pragma:没有缓存 传输编码:分块 服务器:Microsoft IIS/10.0 日期:2019年10月14日星期一15:31:42 GMT 过期:-1 }}


关于如何使用自签名证书按IP地址在本地网络上设置identity server 4.core 3,有什么指导吗?我想在localhost之外为我们的客户端创建一个演示基础设施,以便我们以后可以在客户端站点上发布。

因此我意外地想到了如何使用HTTPS解决本地网络的这种情况。您必须有一个名为localhost的自签名证书才能在identity server启动类ConfigureServices中使用

services.AddSigningCredential("CN=localhost");
然后您必须拥有另一个名为您的.local.domain的自签名证书,并在etc/host文件中设置该域。您还必须使用此证书为identity server站点设置web服务器

如果要从本地网络中的其他计算机连接到identity server,则必须复制您的.local.domain并将其安装到该计算机上。此外,您还必须在该计算机上设置etc/host文件以重定向到web服务器

两台机器上的etc/主机示例

192.168.0.1 your.local.domain
identity server的工作ULR如下所示

https://your.local.domain

来自IdentityServer的BadRequest包含有关请求失败原因的信息,可在“tokenResponse.Error”中找到。那么错误是什么呢?可能是客户端“控制台”未配置为使用客户端凭据授予类型,或者客户端本身可能根本未配置。Discovery文档的可用性与此无关。与令牌请求不同,它是一个没有限制的公共文档。错误为null,错误类型为“协议”,因此on localmachine无效?协议错误可能表明颁发者(创建令牌的人)、访问者(可能接受令牌的人)或有效时间间隔(但可能不是这样)无效。这就是我们要看的地方。通过IdentityServer(客户端/作用域/资源)检查您的配置,并与Api/客户端启动中的配置进行比较。如果我将URL更改为,它可以正常工作。是否有关于在localhost外部设置环境的指导,例如https://和自签名证书?