C# AuthenticationOptions类上出现asp.net core2.0错误的IdentityServer 4

C# AuthenticationOptions类上出现asp.net core2.0错误的IdentityServer 4,c#,authentication,asp.net-core,identityserver4,asp.net-core-2.0,C#,Authentication,Asp.net Core,Identityserver4,Asp.net Core 2.0,我正在使用asp.net core 2.0开发Identity Server 4 在ConfigurationServices()方法中,我添加了: app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions { Authority = "http://localhost:59391", RequireHttpsMetadata = fals

我正在使用asp.net core 2.0开发Identity Server 4

在ConfigurationServices()方法中,我添加了:

app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
        {
            Authority = "http://localhost:59391",
            RequireHttpsMetadata = false,

           ApiName = "api1"
        });
但它给出的编译错误是:

对类型“AuthenticationOptions”的引用声称它是在“Microsoft.AspNetCore.Authentication”中定义的,但找不到它

当我研究汇编代码时:

    namespace Microsoft.AspNetCore.Builder
    {
    public class IdentityServerAuthenticationOptions : Builder.AuthenticationOptions
    {
      // properties goes here
    }
    }
我是基于这个(.net core 1.1)工作的,
AuthenticationOptions
构建错误在这篇文章中讨论了很多,但似乎asp.net core2.0还没有完全支持Identity Server 4。这是真的吗


请分享您对如何解决此错误或如何解决此问题的想法。

没错-asp.net core 2.0中更改了身份验证中间件。我相信有一个,;但是,目前Identity Server文档和示例尚未更新为2.0版

一种选择是使用MicrosoftJWTBearer处理程序来保护api。IdentityServer4.AccessTokenValidation库在后台使用此功能。它看起来像这样(在
ConfigureServices()
内部):

另一个选项是更新代码以使用。我还没有试过,但它看起来像这样:

services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(o =>
{
    o.ApiName = "api1";
    o.Authority = "http://localhost:59391";
    o.RequireHttpsMetadata = false;
}); 
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(o =>
{
    o.ApiName = "api1";
    o.Authority = "http://localhost:59391";
    o.RequireHttpsMetadata = false;
});