Here is some code to reference from the project. I am using the library RestSharp.
string key = File.ReadAllText(@"LF API CloudAccessKey.json");//ServiceKey downloaded from App Configuration Authentication, placed on same folder as this app
string token = CreateClientCredentialsAuthorizationJwt(clientId, servicePrincipalKey, new JsonWebKey(key));
Console.WriteLine(token + "\n");
var client = new RestClient($"https://signin.laserfiche.ca/oauth/token");
var request = new RestRequest();
request.Method = Method.Post;
request.AddHeader("Authorization", $"Bearer {token}");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("grant_type", "client_credentials");
request.AddParameter("application/x-www-form-urlencoded", "grant_type=client_credentials", ParameterType.RequestBody);
request.RequestFormat = DataFormat.Json;
try
{
RestResponse response = client.Execute(request);
Console.WriteLine("response error = " + response.ErrorException);
Console.WriteLine("response content = " + response.Content);
string apiToken = (response.Content);
Console.WriteLine("apitoken for swagger = " + apiToken);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}