'How to properly prepare JsonWebKey for API request?
{
"client_name": "apk1",
"scopes": [
"full"
],
"jwks": {
"keys": [
{
"kty": "RSA",
"e": "AQAB",
"use": "sig",
"kid": "xxxxxxxxxxxxxx",
"alg": "RS512",
"n": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
]
}}
Api expects such json. Can anyone advise me on how to properly deliver jwks? I tried to use the JsonWebKey class but I have no idea how to get the structure like above in json.
var client = new RestClient("url");
var request = new RestRequest("/auth/token", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer " + Authtoken);
RSA rsa = RSA.Create(2048);
var rs256 = new RS256Algorithm(rsa, rsa);
//var token = GenerateToken(1);
RSA rsa = RSA.Create(2048);
var parameters = rsa.ExportParameters(true);
var rsaSecurityKey = new RsaSecurityKey(parameters);
var jwk = JsonWebKeyConverter.ConvertFromRSASecurityKey(rsaSecurityKey);
request.AddJsonBody(new
{
client_name = "client_name",
scopes = new[] { "full" },
jwks = new { keys = new[] { jwk } }
});
var TaskResponse = client.ExecutePostAsync<CreateClientResponse>(request);
TaskResponse.Wait();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
