Asp.net core .net核心客户端没有';t使用IdentityServer v3进行身份验证-访问群体中的偏移量
给定: IdentityServer v3 JavaSCript客户端 Asp核心Api客户端 JavaScript客户端使用identityserver进行身份验证,并使用承载令牌向api发出请求 api配置为使用ressource所有者工作流 问题: 现在我得到: 观众:''。不匹配: validationParameters.ValidAudience:“MyApi”或 validationParameters.Validudiences:“null” 很明显,他们的声音不匹配。 我错过了什么 配置 Identity server中的ApiClient:Asp.net core .net核心客户端没有';t使用IdentityServer v3进行身份验证-访问群体中的偏移量,asp.net-core,identityserver3,Asp.net Core,Identityserver3,给定: IdentityServer v3 JavaSCript客户端 Asp核心Api客户端 JavaScript客户端使用identityserver进行身份验证,并使用承载令牌向api发出请求 api配置为使用ressource所有者工作流 问题: 现在我得到: 观众:''。不匹配: validationParameters.ValidAudience:“MyApi”或 validationParameters.Validudiences:“null” 很明显,他们的声音不匹配。 我错过了
return new Client
{
Enabled = true,
ClientId = "MyApi",
ClientName = "The client for the Groupl Api",
ClientSecrets = new List<Secret>
{
new Secret("foo".Sha256())
},
Flow = Flows.ResourceOwner,
AllowedScopes = ClientConstants.AllowedGrouplScopes()
};
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
var authority = config["identity:authority:url"];
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = authority,
RequireHttpsMetadata = false,
EnableCaching = false,
ApiName = "myApi", //Correct that this is the client id?
ApiSecret = "foo"
});
这里是请求(省略了访问令牌)
更新
当我设置LegacyAudienceValidation=true时,一切正常,但我不确定如何正确处理此问题?原因是身份验证行为已更改。IdentityServer 3不支持多个访问群体。Identityserver 4没有。因此,对于旧的处理方式,
LegacyAudienceValidation
必须设置为true
GET /api/values HTTP/1.1
Host: localhost:59364
Content-Type: application/json
Authorization: Bearer {access_token}