【发布时间】:2023-03-20 15:54:01
【问题描述】:
我正在尝试使用可用的自省示例 here 在请求中发送租户
var client = new HttpClient();
var tokenRequest = new PasswordTokenRequest {
Address = disco.TokenEndpoint,
ClientId = "roclient.reference",
ClientSecret = "secret",
UserName = "user",
Password = "password",
Scope = "api1 api2.read_only"
};
tokenRequest.Parameters.Add( "acr_values", "tenant:mytenant" );
var response = await client.RequestPasswordTokenAsync( tokenRequest );
但是,tenant 参数,服务器端始终为空,从下面的日志中可以看到
[09:54:02 INF] User authentication failed: ["invalid_username_or_password"], request details:
{
"ClientId": "roclient.reference",
"ClientName": "Introspection Client Sample",
"GrantType": "password",
"Scopes": "api1 api2.read_only",
"AuthorizationCode": null,
"RefreshToken": null,
"UserName": "user",
"AuthenticationContextReferenceClasses": null,
"Tenant": null,
"IdP": null,
"Raw": {"acr_values": "tenant:mytenant", "grant_type": "password", "username": "user", "password": "***REDACTED***", "scope": "api1 api2.read_only", "client_id": "roclient.reference", "client_secret": "***REDACTED***"},
"$type": "TokenRequestValidationLog"
}
在请求中发送租户参数的正确方法是什么?
【问题讨论】:
标签: asp.net-core identityserver4 access-token