diff --git a/DevconBoothImages/CodexWrapper.cs b/DevconBoothImages/CodexWrapper.cs index e5140af..ff09382 100644 --- a/DevconBoothImages/CodexWrapper.cs +++ b/DevconBoothImages/CodexWrapper.cs @@ -1,4 +1,5 @@ using CodexOpenApi; +using IdentityModel.Client; using System.Net.Http; using System.Windows; using Utils; @@ -23,12 +24,12 @@ namespace DevconBoothImages { var config = new Configuration(); return new Codexes( - await GetCodex(config.CodexLocalEndpoint), - await GetCodex(config.CodexPublicEndpoint) + await GetCodexWithPort(config.CodexLocalEndpoint), + await GetCodexWithoutPort(config.CodexPublicEndpoint, config.AuthUser, config.AuthPw) ); } - private async Task GetCodex(string endpoint) + private async Task GetCodexWithPort(string endpoint) { var splitIndex = endpoint.LastIndexOf(':'); var host = endpoint.Substring(0, splitIndex); @@ -47,6 +48,17 @@ namespace DevconBoothImages return codex; } + private async Task GetCodexWithoutPort(string endpoint, string user, string pw) + { + var client = new HttpClient(); + client.SetBasicAuthentication(user, pw); + var codex = new CodexApi(client); + codex.BaseUrl = $"{endpoint}/api/codex/v1"; + + await CheckCodex(codex, endpoint); + return codex; + } + private async Task CheckCodex(CodexApi codex, string endpoint) { try diff --git a/DevconBoothImages/Configuration.cs b/DevconBoothImages/Configuration.cs index ea5f0bb..075f0d6 100644 --- a/DevconBoothImages/Configuration.cs +++ b/DevconBoothImages/Configuration.cs @@ -3,7 +3,7 @@ public class Configuration { public string CodexLocalEndpoint { get; } = "http://localhost:8080"; - public string CodexPublicEndpoint { get; } = ""; + public string CodexPublicEndpoint { get; } = "https://api.testnet.codex.storage/storage/node-9"; public string AuthUser { get; } = ""; public string AuthPw { get; } = "";