小编Wil*_*ila的帖子

从 API 中的参考令牌获取用户 ID

我的设置,

  • 使用 MVC 身份存储用户的 IdentityServer,使用http://docs.identityserver.io/en/release/quickstarts/0_overview.html教程创建dotnet new mvc -au Individual并应用,在 localhost 5000 中运行。
  • 一个客户端应用程序,但现在我正在使用邮递员进行测试。
  • 使用 生成的 WEB API,dotnet new webapi在 localhost 5001 中运行。

IdentityServer 资源和客户端配置如下,注意我使用的是引用令牌:

public static IEnumerable<IdentityResource> GetIdentityResources() {
    return new List<IdentityResource>{ new IdentityResources.OpenId() };
}

public static IEnumerable<ApiResource> GetApiResources() {
    return new List<ApiResource>{
        new ApiResource("api_resource", "API Resource") {
            Description= "API Resource Access",
            ApiSecrets= new List<Secret> { new Secret("apiSecret".Sha256()) },
        }
    };
}

public static IEnumerable<Client> GetClients() {
    return new List<Client>{
        new Client { …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core identityserver4 asp.net-core-2.0

2
推荐指数
1
解决办法
6128
查看次数