diff --git a/csharp/App/OpenVpnCertificatesServer/AccToken.cs b/csharp/App/OpenVpnCertificatesServer/AccToken.cs
new file mode 100644
index 000000000..1051797c6
--- /dev/null
+++ b/csharp/App/OpenVpnCertificatesServer/AccToken.cs
@@ -0,0 +1,12 @@
+namespace InnovEnergy.App.OpenVpnCertificatesServer;
+
+internal class AccToken
+{
+ public String token { get; init; }
+ public String bearer { get; init; }
+ public UInt64 idUser { get; init; }
+ public String verification_mode { get; init; }
+ public String idAccessToken { get; init; }
+ public Boolean verification_sent { get; init; }
+ public Boolean success { get; init; }
+}
\ No newline at end of file
diff --git a/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj b/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj
index e44b0a11e..96abef819 100644
--- a/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj
+++ b/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj
@@ -12,5 +12,11 @@
+
+
+
+ PreserveNewest
+
+
diff --git a/csharp/App/OpenVpnCertificatesServer/Program.cs b/csharp/App/OpenVpnCertificatesServer/Program.cs
index 436a5ff6d..024cc61b0 100644
--- a/csharp/App/OpenVpnCertificatesServer/Program.cs
+++ b/csharp/App/OpenVpnCertificatesServer/Program.cs
@@ -32,8 +32,14 @@ public static class Program
private const String CcdDir = VpnDir + "/ccd";
private const String CertsDir = VpnDir + "/certs";
private const String Endpoint = "http://localhost:4000/";
-
- private static readonly AccToken AccToken = JsonSerializer.Deserialize(File.OpenRead("./token.json"))!; //"d4179e69413ad8c507e0965a55bb90fe712184af9c81c196b9d19db5bb083d5f";
+
+ private static AccToken ReadAccessToken()
+ {
+ var content = File.ReadAllText("./token.json");
+ return JsonSerializer.Deserialize(content)!;
+ }
+
+
private const String ManualPw = "MwBRbQb3QaX7l9XIaakq";
private const String QueryPath = "/get_cert";
@@ -136,8 +142,8 @@ public static class Program
Console.WriteLine($"looking up unique id {uniqueId} on VRM");
//var installationName = await LookupInstallationNameByUniqueId(ccdName);
-
- using var vrm = VrmAccount.Token(AccToken.idUser, AccToken.token);
+ var token = ReadAccessToken();
+ using var vrm = VrmAccount.Token(token.idUser, token.token);
var installations = await vrm.GetInstallations();
var installationName = installations
@@ -153,8 +159,8 @@ public static class Program
private static async Task<(String ccdName, String humanReadableName)?> LookupInstallationNameByMachineSerial(String ccdName)
{
Console.WriteLine($"looking up {ccdName} on VRM");
-
- using var vrm = VrmAccount.Token(AccToken.idUser, AccToken.token);
+ var token = ReadAccessToken();
+ using var vrm = VrmAccount.Token(token.idUser, token.token);
var installations = await vrm.GetInstallations();
foreach (var installation in installations)
@@ -268,15 +274,4 @@ public static class Program
return $"{VpnSubnet}{hi}.{lo}";
}
-}
-
-internal interface AccToken
-{
- public String token { get; init; }
- public String bearer { get; init; }
- public UInt64 idUser { get; init; }
- public String verification_mode { get; init; }
- public String idAccessToken { get; init; }
- public Boolean verification_sent { get; init; }
- public Boolean success { get; init; }
}
\ No newline at end of file