ASP.NET Core 2 应用程序中 UseOAuthBearerAuthentication 的等效项是什么?

What is the equivalent of UseOAuthBearerAuthentication in an ASP.NET Core 2 application?

我正在升级接受来自我们的 oAuth 服务器的访问令牌的资源服务器。在 .NET 4.7 中,我有一个如下所示的启动配置:

appBuilder.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

当我添加 Nuget 包 'Microsoft.Owin.Security.OAuth' 时,我收到一条警告,指出该包与目标 .NETCoreApp 不兼容。有道理,但我不确定新包是什么。

我认为我需要的包是 'Microsoft.AspNetCore.Authentication.OAuth'。这允许我添加到启动:

services
     .AddAuthentication(OAuthDefaults.DisplayName)
     .AddOAuth("Bearer", options => options.AuthorizationEndpoint = "uhhh" );

我为什么要配置一个端点,我只是想寻找一个授权令牌,而不是实际提供它们。这看起来像是 oAuth 服务器的设置,而不是收件人。此外,旧的 'OAuthBearerAuthenticationOptions' class 允许我覆盖 'AccessTokenFormat' 之类的东西,但我在新选项中看不到它。

最后,我看到有这样配置 oauth 的选项:

app.UseOAuthAuthentication

但它抱怨它已过时,看起来像 'AddOAuth' 的 Core 1 版本,与 AccessTokenFormat 无关。

有什么想法吗?

Core 不提供这些 API 或其相关令牌服务器的直接替代品。当前的指南是您使用像 IdentityServer4 这样的服务器以及 AddJwtBearerAuthentication。