public static async Task<AppTokenResult> RenewAccessTokenAsync(OAuthTicket ticket)
        {
            string oldRefreshToken = ticket.RefreshToken;
            AppTokenResult appToken = null;

            if (!string.IsNullOrEmpty(oldRefreshToken))
            {
                appToken = await MicrosoftAccountOAuth.RedeemRefreshTokenAsync(msa_client_id, msa_client_secret, oldRefreshToken);
                SaveRefreshToken(appToken.RefreshToken);
            }

            return appToken;
        }
        public static async Task <AppTokenResult> RenewAccessTokenAsync(OAuthTicket ticket)
        {
            string         oldRefreshToken = ticket.RefreshToken;
            AppTokenResult appToken        = null;

            if (!string.IsNullOrEmpty(oldRefreshToken))
            {
                appToken = await MicrosoftAccountOAuth.RedeemRefreshTokenAsync(msa_client_id, msa_client_secret, oldRefreshToken);

                SaveRefreshToken(appToken.RefreshToken);
            }

            return(appToken);
        }
        private async Task SignIn()
        {
            Connection = await OAuthAuthenticator.SignInToMicrosoftAccount(this);
            if (null != Connection)
            {
                WebClient wc = new WebClient();
                string profile = "";

                profile = wc.DownloadString("https://apis.live.net/v5.0//me?access_token=" + Connection.AccessToken);
                var user = Newtonsoft.Json.JsonConvert.DeserializeObject<UserObject>(profile);
  
                //ready
             
                Properties.Settings.Default.LiveIdWWTId = user.Id;
                Properties.Settings.Default.LiveIdUser = user.Name;
                Properties.Settings.Default.LiveIdToken = Connection.AccessToken;

            }

        }