【发布时间】:2025-12-05 22:05:02
【问题描述】:
我是 Identity Server 的新手,对身份和访问令牌的主题感到困惑。我了解访问令牌旨在保护资源(即 Web api),并且身份令牌用于进行身份验证。但是,每当我调用 /connect/token 时,我总是会收到一个“access_token”。在请求中,我询问了一个具有各种范围和声明的客户。
new Client
{
ClientId = "Tetris",
ClientName = "Tetris Web Api",
AccessTokenLifetime = 60*60*24,
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
RequireClientSecret = false,
AllowedScopes = {"openid", "TetrisApi", "TetrisIdentity"}
}
public static IEnumerable<ApiResource> GetApiResources()
{
return new[]
{
new ApiResource("TetrisApi", "Tetris Web API", new[] { JwtClaimTypes.Name, JwtClaimTypes.Role, "module" })
};
}
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResource
{
Name = "TetrisIdentity",
UserClaims =
new[]
{
JwtClaimTypes.Name,
JwtClaimTypes.Role,
JwtClaimTypes.GivenName,
JwtClaimTypes.FamilyName,
JwtClaimTypes.Email,
"module",
"module.permissions"
}
}
};
}
有什么想法吗?我在快速入门中没有看到使用身份令牌的示例。
谢谢!
【问题讨论】:
标签: identityserver4