gpt4 book ai didi

identityserver4 - 您如何在 IdentityServerr4 中请求身份 token (id_token)

转载 作者:行者123 更新时间:2023-12-02 04:00:31 24 4
gpt4 key购买 nike

我是 Identity Server 的新手,对身份和访问 token 的主题感到困惑。我知道访问 token 是为了保护资源(即 web api)并且身份 token 用于身份验证。但是,每当我调用/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"
}
}
};
}

下面是 postman 的副本: enter image description here

有什么想法吗?我在快速入门中没有看到使用身份 token 的示例。

谢谢!

最佳答案

密码授予类型不支持身份 token 。请参阅 RFC6749。

您在这里可以做的最好的事情是使用访问 token 为使用 userinfo 端点的用户获取声明。

建议使用交互式流程(如隐式或混合)进行最终用户身份验证。

关于identityserver4 - 您如何在 IdentityServerr4 中请求身份 token (id_token),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42123810/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com