ASP.NET Core 2应用程序中的UseOAuthBearerAuthentication的等价物是什么? [英] What is the equivalent of UseOAuthBearerAuthentication in an ASP.NET Core 2 application?
本文介绍了ASP.NET Core 2应用程序中的UseOAuthBearerAuthentication的等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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’类允许我重写‘AccessTokenFormat’之类的内容,但我在新选项中看不到这一点。
最后,我看到有这样配置OAuth的选项:
app.UseOAuthAuthentication
但它抱怨它已过时,看起来像‘AddOAuth’的Core 1版本,而与AccessTokenFormat无关。
有什么想法吗?
推荐答案
核心不提供对这些API或其关联令牌服务器的直接替代。目前的指导意见是,您可以使用类似于标识服务器4的服务器和AddJwtBearerAuthentication。
这篇关于ASP.NET Core 2应用程序中的UseOAuthBearerAuthentication的等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文