GetDiscoveryDocumentAsync: "An invalid request URI was provided. The request URI must either be an a



我已经检查了SO上的大部分问题,但没有找到我的答案。

我正在尝试从身份服务器获取JWT令牌。

方法如下:

  var discoveryDocument = new DiscoveryDocumentRequest
            {
                Address = "https://admin.blabla.app:5000/",
                Policy =
                {
                    RequireHttps = false
                }
            };
  var auth = httpClient.GetDiscoveryDocumentAsync(discoveryDocument).Result;

得到的错误是An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.

DiscoveryDocumentRequest

{
    "Policy": {
        "LoopbackAddresses": [
            "localhost",
            "127.0.0.1"
        ],
        "Authority": "https://admin.blabla.app:5000",
        "AuthorityValidationStrategy": {},
        "RequireHttps": false,
        "AllowHttpOnLoopback": true,
        "ValidateIssuerName": true,
        "ValidateEndpoints": true,
        "EndpointValidationExcludeList": [],
        "AdditionalEndpointBaseAddresses": [],
        "RequireKeySet": true
    },
    "Address": "https://admin.blabla.app:5000/",
    "ClientId": null,
    "ClientSecret": null,
    "ClientAssertion": {
        "Type": null,
        "Value": null
    },
    "ClientCredentialStyle": 1,
    "AuthorizationHeaderStyle": 0,
    "Parameters": [],
    "Version": {
        "Major": 1,
        "Minor": 1,
        "Build": -1,
        "Revision": -1,
        "MajorRevision": -1,
        "MinorRevision": -1
    },
    "Content": null,
    "Method": {
        "Method": "GET"
    },
    "RequestUri": null,
    "Headers": [
        {
            "Key": "Accept",
            "Value": [
                "application/json"
            ]
        }
    ],
    "Properties": {}
}

这个代码是在一个windows服务上。

有趣的事实:相同的代码可以在不同的windows机器上运行。为什么?有什么问题吗?

参考这个例子,请写:

 var client = new HttpClient();
            var disco = await client.GetDiscoveryDocumentAsync("https://admin.blabla.app:5000/");
            if (disco.IsError)
            {
                Console.WriteLine(disco.Error);
                return;
            }

请检查您的URL https://admin.blabla.app:5000/您的错误与您的URL有关,您可以通过https://demo.identityserver.io/测试您的代码

相关内容

  • 没有找到相关文章

最新更新