IdentityServer4问题

问题描述:

我正在使用IdentityServer4创建Web API安全性。我通过在控制台管理器中键入以下语法来安装identityserver4软件包:Install-Package IdentityServer4-Pre。它被成功安装。现在我不能在我的项目中引用它。 这里是安装后我project.json代码:IdentityServer4问题

{ 
    "webroot": "wwwroot", 
    "version": "1.0.0-*", 

    "dependencies": { 
     "Microsoft.AspNet.Server.IIS": "1.0.0-beta5", 
     "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5", 
     "IdentityServer4": "1.0.0-rc1-update2" 
    }, 

    "commands": { 
     "web": "Microsoft.AspNet.Hosting --config hosting.ini" 
    }, 

    "frameworks": { 
     "dnx451": { }, 
     "dnxcore50": { } 
    }, 

    "publishExclude": [ 
     "node_modules", 
     "bower_components", 
     "**.xproj", 
     "**.user", 
     "**.vspscc" 
    ], 
    "exclude": [ 
     "wwwroot", 
     "node_modules", 
     "bower_components" 
    ] 
} 

所以,现在我已经创建了一个客户端类用下面的代码:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Threading.Tasks; 

namespace LearningIdentityServer4.OAuth 
{ 
    public class Clients 
    { 
     public static IEnumerable<Client> Get() 
     { 
      return new[] 
      { 
       new Client 
       { 
        ClientId = "myApi", 
        ClientSecrets = new List<Secret> 
        { 
         new Secret("secret".Sha256()) 
        }, 
        ClientName = "My lovely Api", 
        Flow = Flows.ResourceOwner, 
        AllowedScope = 
        { 
         Constants.StandardScope.OpenId, 
         "read" 
        }, 
        Enabled = true 
       } 
      }; 
     } 
    } 
} 

所以我得到很多的错误。当我将鼠标悬停我的鼠标,让我们说第一个客户,我得到的唯一选择是添加包IdentityServer3 2.1.1

那么,如何引用,而不是IdentityServer3 2.1.1

我会期待的IdentityServer4听取您的意见。

谢谢,Somad

这些框架是完全过时的。

要使用identityserver4您需要(至少)取决于netcoreapp 1.0框架与一些额外的依赖关系。更换你的框架,你project.json以下几点:

"frameworks": { 
"netcoreapp1.0": { 
    "imports": [ 
    "dotnet5.6", 
    "portable-net45+win8" 
    ] 
} 
}, 

另见samples。我假设你的工具已经过时,或者你再次开放一个旧项目。 ASP.NET Core有许多变化。