【发布时间】:2019-09-17 15:56:48
【问题描述】:
我有使用默认 Web MVC 项目的开箱即用身份验证的 webhook。
我现在尝试使用 Identity Server 将其移植到 Web API。
使用 Postman,当我进行身份验证时,我会得到一个不记名令牌。然后我收集该不记名令牌并将其附加到新的 GET 请求中,尝试访问 api/webhooks/registrations(以查看是否可以检索过滤器列表)
但我得到以下信息。
"message": "Could not determine the user ID from the given principal.",
"exceptionMessage": "Could not determine the user ID from the given principal.",
"exceptionType": "System.InvalidOperationException",
"stackTrace": " at Microsoft.AspNet.WebHooks.WebHookUser.GetUserIdAsync(IPrincipal user)\r\n at Microsoft.AspNet.WebHooks.Controllers.WebHookRegistrationsController.<GetUserId>d__13.MoveNext()"
如果我忽略 webhook 方法并使用相同的凭据访问另一个 API 方法,它可以工作,所以这是 WebHooks Auth 特有的。
我确实找到了这个,但我无法通过将 Claims 枚举更改为其他内容来使其工作。
Problems registering a receiver with Microsoft Webhooks
那么,任何人都可以解释为什么我的身份无法正常工作,或者建议其他方法来解决这个问题吗?
【问题讨论】: