c# - 如何从身份服务器 3 获取多个范围的凭据?
问题描述
我正在尝试使用IdentityModel.TokenClient
. 获取一个角色的凭据工作正常,但我需要在一个请求中获取两个范围的凭据。范围是“api”和“myrole”。
据我所知,应该通过简单地用空格分隔多个角色来完成,如下所示:
var client = new TokenClient(
"https://theidentityserver.com/connect/token",
"myclient",
"mysecret");
var result = await client.RequestClientCredentialsAsync("api myrole");
这会生成一个请求:
> POST https://theidentityserver.com/connect/token HTTP/1.1 Connection:
> Keep-Alive Content-Type: application/x-www-form-urlencoded Accept:
> application/json Authorization: Basic [auth token here]
> Content-Length: 46 Host: theidentityserver.com
>
> grant_type=client_credentials&scope=api+myrole
并产生响应:
{“错误”:“无效范围”}
如您所见,TokenClient
生成一个请求,其中范围由加号而不是空格分隔。有什么办法可以解决这个问题还是我做错了什么?
解决方案
推荐阅读
- google-chrome - Blazor Set-Cookie 无效
- javascript - npm run build 不起作用,而 npm run dev 起作用,NuxtJS
- python - Pytorch affine_grid 在图像和地标上的行为不同
- android - Create Zip file where the contents are a bitmaps for Android Kotlin
- pandas - 按日期对数据框进行分组并创建一个新的平均分数数据框
- c# - 使用数据绑定,如何将包含表情符号的文本绑定到标签并使其正确显示?
- ios - 如何在导航栏下显示侧边菜单?
- c - C中的阿姆斯特朗数
- java - 如何阻止java邮件打开这么多连接
- swiftui - 如何在 SwiftUI 中使整个列表行成为 NavigationLink