private async Task <bool> GetTokensAsync(UserAccount account, ClientPortionTransferItem project) { var proxy = new ProxyAcquisition(); var ret = await proxy.GetTokenInfoAsync(account, project); txtTokenAcquire.Text = ret.TokenAcquire; txtToken.Text = ret.TokenKey; return(true); }
public async Task <TokenAcquisition> GetTokenInfoAsync(UserAccount account, ClientPortionTransferItem project) { var tokenInfo = new TokenAcquisition(); if (account != null && account.HasValue && project != null) { var cookieJar = new CookieContainer(); using (var handler = new HttpClientHandler { CookieContainer = cookieJar, UseCookies = true, }) { using (var client = CreateHttpClient(handler)) { var Uri = CreateUri($"/CommissionedAcquisition?projectId={project.projectId}¤tPrice={project.minTransferingPrice}"); foreach (Cookie token in account.TokenOffical) { cookieJar.Add(Uri, new Cookie(token.Name, token.Value)); } var response = await client.GetAsync(Uri); if (response.IsSuccessStatusCode) { var html = await response.Content.ReadAsStringAsync(); RetrieveToken(html, tokenInfo); } } } } return(tokenInfo); }