小编Mik*_*ike的帖子

验证 Oauth Bearer 令牌,Microsoft.Owin.Security.Jwt 4.x 中缺少 IIssuerSecurityTokenProvider

我正在尝试让我的 .Net Web API(使用 OWIN 的 Azure API 应用程序)接受用于 client_credentials 授予的 OAuth Bearer 令牌,但我不断收到 401 Unauthorized。

似乎所有 Microsoft 示例都已过时(不符合 Owin 的最新 nuget 包)。

JwtFormat 需要一个 IIssuerSecurityTokenProvider,但它不再存在 - 相反,JwtFormat 需要一个 IIssuerSecurityKeyProvider,但我无法理解如何使用它。

Azure OAuth 服务器正在运行

我已在 Azure Active Directory 中注册了两个应用程序(api 和客户端)。由于这只是快速演示,我将向您提供所有 id 和秘密;)

我可以从 Azure AD 获取令牌,请参阅https://reqbin.com/817shtc2以获取完整的请求,到目前为止一切顺利。

应用程序编程接口

客户端ID:44cf7574-88a2-42d6-9497-bff43cc8dc09

端点https ://apim-demo-mglentoft.azure-api.net/api/Values (GET)

客户

客户端ID:5f7ee334-b8db-46d3-972f-09f52e186d1d

秘密:ggKp94]HZHWZ.c*5wUC?ToSVfknyqLB3

我按照https://github.com/azureadquickstarts/appmodelv2-nativeclient-dotnet上的示例进行操作,但它引用了 Microsoft.Owin.Security.Jwt.IIssuerSecurityTokenProvider,它在 nuget v4.0.1.0 中不存在。

我尝试仅注释掉 JwtFormat 的第二个参数,但这不起作用。有什么想法如何使用 Microsoft.Owin.Security.Jwt.IIssuerSecurityKeyProvider 来实现此功能吗?

下面是整个startup.cs

我可以使用 .Net Core 来实现此功能,但由于各种原因,我必须坚持使用 .Net Framework 4.7.2

using …
Run Code Online (Sandbox Code Playgroud)

authentication token azure oauth-2.0 owin

1
推荐指数
1
解决办法
5389
查看次数

标签 统计

authentication ×1

azure ×1

oauth-2.0 ×1

owin ×1

token ×1