Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.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# 标识服务器获取“错误”:“无效的\u作用域”_C#_Asp.net Core_Identityserver4 - Fatal编程技术网

C# 标识服务器获取“错误”:“无效的\u作用域”

C# 标识服务器获取“错误”:“无效的\u作用域”,c#,asp.net-core,identityserver4,C#,Asp.net Core,Identityserver4,尝试获取自定义范围值的令牌时出错。下面是我的代码段 public static IEnumerable<ApiResource> GetApis() => new List<ApiResource> { new ApiResource("ApiOne","ApiOne",new []{ "ApiOne"}) }; public sta

尝试获取自定义范围值的令牌时出错。下面是我的代码段

public static IEnumerable<ApiResource> GetApis() =>
        new List<ApiResource>
        {
             new ApiResource("ApiOne","ApiOne",new []{ "ApiOne"})
        };
public static IEnumerable<Client> GetClients() =>
        new List<Client> { new Client
        {
            ClientId="client1",
            ClientSecrets={ new Secret("secret1".Sha256())},
            AllowedGrantTypes={GrantType.ClientCredentials},
            AllowedScopes={"ApiOne"},
            AllowOfflineAccess=true,
            
        },
        };

在配置中添加ApiScope

public static List<ApiScope> Get()
    {
        return new List<ApiScope>
       {
           new ApiScope
           {
               Name = "ApiOne",
               Emphasize=true,
           },
           new ApiScope
           {
               Name = "ApiTwo",
               Emphasize=true,
           },
       };
    }

在配置中添加ApiScope

public static List<ApiScope> Get()
    {
        return new List<ApiScope>
       {
           new ApiScope
           {
               Name = "ApiOne",
               Emphasize=true,
           },
           new ApiScope
           {
               Name = "ApiTwo",
               Emphasize=true,
           },
       };
    }

你的客户端配置是什么?你在定义API的作用域吗?你的客户端配置是什么?你在定义API的作用域吗?