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 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 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); }