Example #1
0
        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);
            }
        }
Example #2
0
 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);
 }
Example #3
0
        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);
        }