我正在处理 ASP.NET API(内置于 Core 2.1),当我尝试从测试应用程序调用它时,我收到 401 Unauthorized。但是,据我所知,访问令牌很好。有没有办法从 ASP.NET Core 2.1 中的身份验证处理程序中获取有关无效内容的更多详细信息?如果我能对令牌有什么问题有所了解,我应该能够找到解决方案来纠正它,但现在我在黑暗中蹒跚而行,只是尝试了各种事情(很可能,我只是在做更差)。
2 回答
![?](http://img1.sycdn.imooc.com/545867790001599f02200220-100-100.jpg)
摇曳的蔷薇
TA贡献1793条经验 获得超6个赞
检查日志或服务器的事件查看器。
对于您的错误,请检查您是否app.UseAuthentication()作为 中的第一个方法调用Configure(),甚至在UseMVC().
如果您提到了错误的子代码,这将有所帮助:
401.1: Access is denied due to invalid credentials.
401.2: Access is denied due to server configuration favoring an alternate authentication method.
401.3: Access is denied due to an ACL set on the requested resource.
401.4: Authorization failed by a filter installed on the Web server.
401.5: Authorization failed by an ISAPI/CGI application.
401.7: Access denied by URL authorization policy on the Web server.
- 2 回答
- 0 关注
- 285 浏览
添加回答
举报
0/150
提交
取消