2016-09-28 69 views
0

我正在使用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

回答

4

這些框架是完全過時的。

要使用identityserver4您需要(至少)取決於netcoreapp 1.0框架與一些額外的依賴關係。更換你的框架,你project.json以下幾點:

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

另見samples。我假設你的工具已經過時,或者你再次開放一箇舊項目。 ASP.NET Core有許多變化。