Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IdentityServer 4用户信息终结点返回禁止状态_C#_Identityserver4 - Fatal编程技术网

C# IdentityServer 4用户信息终结点返回禁止状态

C# IdentityServer 4用户信息终结点返回禁止状态,c#,identityserver4,C#,Identityserver4,我刚开始使用identityserver4,无法理解用户信息端点返回禁止状态的原因 public static IEnumerable<Client> GetClients() { return new List<Client> { new Client { ClientId = "client1", Allowe

我刚开始使用identityserver4,无法理解用户信息端点返回禁止状态的原因

    public static IEnumerable<Client> GetClients()
    {
        return new List<Client>
        {
             new Client
             {
               ClientId = "client1",
               AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
               ClientSecrets =
               {
                   new Secret("secret".Sha256())
               },
               AllowedScopes =
               {
                     "api1",
                     IdentityServerConstants.StandardScopes.OpenId,
                     IdentityServerConstants.StandardScopes.Profile,
               },
               IncludeJwtId = true,
               RequireConsent = false,
               AlwaysIncludeUserClaimsInIdToken = true,
               AlwaysSendClientClaims = true,

             }
        };
    }. 
为什么我在userinfo端点中获得禁止的状态码?
感谢您的帮助

首先检查您的客户端配置。在GetClients中有一个ClientId=client1,然后在令牌客户端构建中有var tokenClient=new TokenClientdisco.TokenEndpoint,mvc,secret

您的客户ID不正确。这个mvc来自哪里

    public static List<TestUser> GetUsers()
    {
        return new List<TestUser>
        {
            new TestUser
            {
              SubjectId = "1",
              Username = "admin",
              Password = "admin",
              Claims = new List<Claim>
              {
                  new Claim("Name", "test")
              }
            }
        };
    }
        var disco = DiscoveryClient.GetAsync("https://localhost:44327").Result;
        var tokenClient = new TokenClient(disco.TokenEndpoint, "mvc", "secret");
        var tokenResponse = tokenClient.RequestResourceOwnerPasswordAsync("api1","admin","admin").Result;
        if (tokenResponse.IsError)
        {
            Console.WriteLine(tokenResponse.Error);
            return;
        }
        var client = new HttpClient();
        client.SetBearerToken(tokenResponse.AccessToken);

        var res =  client.GetAsync(disco.UserInfoEndpoint).Result;
        var claims = res.Content;