public class Program { public static void Main(string[] args) { var config = new ConfigurationBuilder() .AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(),"hosting.json"), optional: false) .Build(); var useHttps = false; bool.TryParse(config !=null ? config["useHttps"] : "false", out useHttps); IWebHost host = null; if (useHttps) { var fileInfo = new FileInfo(config["certName"]); X509Certificate2 cert = new X509Certificate2(fileInfo.FullName, config["certPwd"]); host = new WebHostBuilder() .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup() .UseKestrel(options => { options.Listen(IPAddress.Loopback, 5000); options.Listen(IPAddress.Any, 4430, listenOptions => { listenOptions.UseHttps(cert); }); }) .UseIISIntegration() .Build(); } else { host = new WebHostBuilder() .UseStartup() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseUrls(config["url"]) .Build(); } host.Run(); } } public class NetworkExtensions { public static IConfiguration Configuration { get; set; } public static ILogger Log { get; set; } /// /// Flurl to get api /// /// /// /// This param is used to Perform OKTA api Retry /// public static async Task Get(OktaRequestDto requestDto, OKTARateLimit rateLimit = null) { using (MiniProfiler.Current.Step("Okta : Get")) { // OKTA code execution starts here. string url = requestDto.BaseUrl .AppendPathSegment(requestDto.ApiName + requestDto.Query); // Handle all querystring append. if (requestDto.QueryStrings != null && requestDto.QueryStrings.Count > 0) { foreach (var querystring in requestDto.QueryStrings.Keys) { //FLURL is encoding the value, To ensure the value is passed correct, added true param to stop default behavior url = url.SetQueryParam(querystring, requestDto.QueryStrings[querystring], true); } } var response = await url.WithHeader("Authorization", requestDto.ApiKey).GetJsonAsync(); Log.Information("response => " + JsonConvert.SerializeObject(response)); return response; catch (FlurlHttpException ex) { // there is an OKTA exception, return the default value, The exception is captured in the FLURLConfig OneLoginException ole = new OneLoginException(ex, requestDto); throw ole; } catch (Exception ex) { throw ex; } } } }