I'm attempting to call Identity Server 4 with Flurl
(我正在尝试使用Flurl调用Identity Server 4)
Im getting a 400 back from the ID server.
(我从ID服务器取回了400。)
The credentials etc work when I make the call with PostMan or with the methods available in IdentityModel.Client.(当我使用PostMan或IdentityModel.Client中可用的方法进行呼叫时,凭据等起作用。)
I am unsure about the Post ie PostUrlEncodedAsync As you can see I have tried various combinations.
(我不确定Post即PostUrlEncodedAsync如您所见,我尝试了各种组合。)
This.. does not work
(这..行不通)
var address = "http://localhost:8027/connect/token";
var x = await address
.WithBasicAuth("clientName", "secretValue")
.SetQueryParams(
new
{
GrantType = "client_credentials",
Scope = "requiredScope"
}
)
.PostUrlEncodedAsync(new { });
//.SendAsync(HttpMethod.Post, null, CancellationToken.None);
//.SendAsync(HttpMethod.Post, y);
This.. does.
(这..确实。)
var apiClientCredentials = new ClientCredentialsTokenRequest()
{
Address = "http://localhost:8027/connect/token",
ClientId = "clientName",
ClientSecret = "secretValue",
Scope = "requiredScope"
};
var client = new HttpClient();
var tokenResponse = await client.RequestClientCredentialsTokenAsync(apiClientCredentials);
if (tokenResponse.IsError)
{
}
I can see that deep doen inside 'RequestClientCredentialsTokenAsync' it does parameters.Add to add grant type and scope hence I have added those as params.
(我可以看到在'RequestClientCredentialsTokenAsync'中的深层区域确实有参数。添加以添加授权类型和范围,因此我将它们添加为参数。)
Have also tried adding the client id and secret to the query params.
(还尝试将客户端ID和密码添加到查询参数中。)
Same 400 message.
(相同的400条消息。)
Any help greatly appreciated.
(任何帮助,不胜感激。)
ask by S Rosam translate from so