我已经在.Net Core API项目中实现了IdentityServer 4。
我创建了一个std::hash<std::string> strHash;
strHash(data1);
strHash(data2);
客户端并允许使用openID范围。
Resource Owner Credentials Grant
这是我的客户代码:
var builder = services.AddIdentityServer()
.AddInMemoryIdentityResources(Config.Ids)
.AddInMemoryApiResources(Config.Apis)
.AddInMemoryClients(Config.Clients).
AddResourceOwnerValidator<CustomResourceOwnerPasswordValidator>();
我还在AddInMemoryIdentityResources()中添加了所有范围。
但是响应中不包含ID令牌。
new Client
{
ClientId = "resourceownerclient",
AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
AccessTokenType = AccessTokenType.Jwt,
AlwaysSendClientClaims = true,
Enabled = true,
ClientSecrets= new List<Secret> { new Secret("Secret".Sha256()) },
AllowedScopes = {
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.OfflineAccess,
"api1"
}
}
查看关于SO的另一个问题,即Open ID Connect是否支持资源所有者凭证授予。
如何在响应中获取ID令牌?
刷新令牌调用返回ID令牌,但这是一个bug。