Kod*_*zzz 3 c# asp.net-core identityserver4
我在尝试获取自定义范围值的令牌时遇到错误。下面是我的代码片段。
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,
},
};
Run Code Online (Sandbox Code Playgroud)
在配置中添加 ApiScope
public static List<ApiScope> Get()
{
return new List<ApiScope>
{
new ApiScope
{
Name = "ApiOne",
Emphasize=true,
},
new ApiScope
{
Name = "ApiTwo",
Emphasize=true,
},
};
}
Run Code Online (Sandbox Code Playgroud)
在启动文件中添加
.AddInMemoryApiScopes(Configuration.Get());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3715 次 |
| 最近记录: |