【发布时间】:2016-09-28 20:53:28
【问题描述】:
我正在使用 IdentityServer4 创建 Web API 安全性。我通过在控制台管理器中键入以下语法安装了 identityserver4 包:Install-Package IdentityServer4 -Pre。它安装成功。现在我无法在我的项目中引用它。 这是我安装后的project.json代码:
{
"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
}
};
}
}
}
所以我得到了很多错误。当我将鼠标悬停在第一个客户端上时,我得到的唯一选项是 Add Package IdentityServer3 2.1.1
那么我如何引用 IdentityServer4 而不是 IdentityServer3 2.1.1
我期待收到您的来信。
谢谢,索马德
【问题讨论】:
-
您还可以在此处查看有关如何设置的示例:github.com/georgekosmidis/IdentityServer4.SetupSample
标签: identityserver4