using CmlLib.Core; using CmlLib.Core.Auth; using XboxAuthNet.Game.Msal; using CmlLib.Core.Auth.Microsoft; namespace Plombir; static public class Utils { public static async Task> GetAllMcVersions() { return await Task.Run(async () => { var ln = new MinecraftLauncher(); var result = new List(); foreach (var x in await ln.GetAllVersionsAsync()) { result.Add(x.Name); } return result; }); } /* ID is approved, we are so ready. */ public static async Task? GetLicensedSession() { try { var app = await MsalClientHelper.BuildApplicationWithCache( "d87c436c-aad0-46ea-b392-b53b3ed787b1" ); var loginHandler = JELoginHandlerBuilder.BuildDefault(); var authenticator = loginHandler.CreateAuthenticatorWithNewAccount(default); authenticator.AddMsalOAuth(app, msal => msal.SystemBrowser()); // authenticator.AddMsalOAuth(app, msal => msal.DeviceCode(deviceCode => // { // Console.WriteLine(deviceCode.Message); // return Task.CompletedTask; // })); // Im too lazy to implement this type of auth authenticator.AddMsalOAuth(app, msal => msal.Silent()); authenticator.AddXboxAuthForJE(xbox => xbox.Basic()); authenticator.AddJEAuthenticator(); return await authenticator.ExecuteForLauncherAsync(); } catch (Exception e) { throw new Exception($"Failed to authentificate! {e}"); } } }