public async Task <bool> Validate() { if (isOffline) { throw new MCLoginException("Unable to validate offline session"); } if (!await MCLogin.CheckConnection()) { throw new MCLoginException(); } ValidateRequest req = new ValidateRequest { AccessToken = accessToken, ClientToken = clientToken }; try { await MCHttpHelper.PostYggdrasil(MCLogin.AUTHSERVER_URL + "/validate", req); return(true); } catch (MCLoginException) { return(false); } }
public Task <AssetGroupIndexDefinition> GetAssetIndex(AssetGroup ag) { if (ag.DescribedBy.Url == null) { throw new MCDownloadException("Asset group doesn't have any url."); } return(MCHttpHelper.Get <AssetGroupIndexDefinition>(ag.DescribedBy.Url)); }
public Task <VersionManifestDefinition> GetVersion(MCVersion v) { if (v.Url == null) { throw new MCDownloadException("Version doesn't have any URL"); } return(MCHttpHelper.Get <VersionManifestDefinition>(v.Url)); }
public static async Task Signout(string email, string password) { if (!await CheckConnection()) { throw new MCLoginException(); } SignoutRequest req = new SignoutRequest { Username = email, Password = password }; await MCHttpHelper.PostYggdrasil(AUTHSERVER_URL + "/signout", req); }
public static async Task <bool> CheckConnection() { try { await MCHttpHelper.Head(AUTHSERVER_URL); return(true); } catch (HttpRequestException) { return(false); } }
public async Task Invalidate() { if (isOffline) { throw new MCLoginException("Unable to invalidate offline session"); } if (!await MCLogin.CheckConnection()) { throw new MCLoginException(); } InvalidateRequest req = new InvalidateRequest { AccessToken = accessToken, ClientToken = clientToken }; await MCHttpHelper.PostYggdrasil(MCLogin.AUTHSERVER_URL + "/invalidate", req); }
public static async Task <MCSession> Login(string email, string password) { if (!await CheckConnection()) { throw new MCLoginException(); } AuthenticateRequest req = new AuthenticateRequest { Agent = new AuthenticateRequest.AgentData { Name = "Minecraft", Version = 1 }, Username = email, Password = password, ClientToken = Guid.NewGuid().ToString(), RequestUser = true }; AuthenticateResponse r = await MCHttpHelper.PostYggdrasil <AuthenticateResponse, AuthenticateRequest>(AUTHSERVER_URL + "/authenticate", req); return(new MCSession(r, email)); }
public async Task Refresh() { if (isOffline) { throw new MCLoginException("Unable to refresh offline session"); } if (!await MCLogin.CheckConnection()) { throw new MCLoginException(); } RefreshRequest req = new RefreshRequest { AccessToken = accessToken, ClientToken = clientToken, RequestUser = true }; RefreshResponse res = await MCHttpHelper.PostYggdrasil <RefreshResponse, RefreshRequest>(MCLogin.AUTHSERVER_URL + "/refresh", req); accessToken = res.AccessToken; selected = Array.IndexOf(profiles, res.SelectedProfile); userId = res.User.ID; userProperties = res.User.Properties.ToDictionary(x => x.Name, x => x.Value); }
public async Task <IEnumerable <VersionDefinition> > GetAllVersions() { return((await MCHttpHelper.Get <VersionList>("https://launchermeta.mojang.com/mc/game/version_manifest.json")).Versions); }