public async Task<string> Download(string url, CancellationTokenSource token = null) { _currentToken = token ?? new CancellationTokenSource(); var handler = _httpClientFactory.GetHandler(); var outerHandler = new RetryHandler(handler, 3); var client = _httpClientFactory.Get(outerHandler); var msg = await client.GetAsync(url, _currentToken.Token); if (!msg.IsSuccessStatusCode) return "Something derped"; var result = await msg.Content.ReadAsStringAsync(); return result; }
public async Task<IEnumerable<IdentityProviderInformation>> GetIdentityProviderListAsync(Uri identityProviderListServiceEndpoint) { var clientFactory = Mvx.Resolve<IHttpClientFactory>(); var handler = clientFactory.GetHandler(); var outerHandler = new RetryHandler(handler); var client = clientFactory.Get(outerHandler); var json = await client.GetStringAsync(identityProviderListServiceEndpoint); var identityProviders = JsonConvert.DeserializeObject<IEnumerable<IdentityProviderInformation>>(json); var windowsLiveId = identityProviders.FirstOrDefault(i => i.Name.Equals("Windows Live™ ID", StringComparison.OrdinalIgnoreCase)); if (windowsLiveId != null) { var separator = windowsLiveId.LoginUrl.Contains("?") ? "&" : "?"; windowsLiveId.LoginUrl = string.Format(CultureInfo.InvariantCulture, "{0}{1}pcexp=false", windowsLiveId.LoginUrl, separator); } return identityProviders; }