Initializes the AuthToken class. This must be called before any other methods. The folder to store the config file in. Default is ".spacetime_csharp_sdk". The name of the config file. Default is "settings.ini". The root folder to store the config file in. Default is the user's home dir
(string configFolder = ".spacetime_csharp_sdk", string configFile = "settings.ini", string? configRoot = null)
| 102 | /// <param name="configRoot">The root folder to store the config file in. Default is the user's home directory.</param> |
| 103 | /// </summary> |
| 104 | public static void Init(string configFolder = ".spacetime_csharp_sdk", string configFile = "settings.ini", string? configRoot = null) |
| 105 | { |
| 106 | configRoot ??= Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); |
| 107 | |
| 108 | if (Environment.GetCommandLineArgs().Any(arg => arg == "--client")) |
| 109 | { |
| 110 | int clientIndex = Array.FindIndex(Environment.GetCommandLineArgs(), arg => arg == "--client"); |
| 111 | var configFileParts = configFile.Split("."); |
| 112 | configFile = $"{configFileParts[0]}_{Environment.GetCommandLineArgs()[clientIndex + 1]}.{configFileParts[1]}"; |
| 113 | } |
| 114 | |
| 115 | settingsPath = Path.Combine(configRoot, configFolder, configFile); |
| 116 | |
| 117 | if (File.Exists(settingsPath)) |
| 118 | { |
| 119 | token = |
| 120 | File.ReadLines(settingsPath) |
| 121 | .FirstOrDefault(line => line.StartsWith(PREFIX)) |
| 122 | ?[PREFIX.Length..]; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | /// <summary> |
| 127 | /// This is the auth token that was saved to local storage. Null if not never saved. |