Fix missing proxy config in ExchangeCode method (#363)

This commit is contained in:
Brandon 2019-07-30 09:54:02 -07:00 committed by Jonas Dellinger
parent 3851c95d4d
commit fb11f0deb7

View File

@ -55,16 +55,9 @@ namespace SpotifyAPI.Web.Auth
new KeyValuePair<string, string>("refresh_token", refreshToken)
};
HttpClientHandler handler = ProxyConfig.CreateClientHandler(ProxyConfig);
HttpClient client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("Authorization", GetAuthHeader());
HttpContent content = new FormUrlEncodedContent(args);
HttpResponseMessage resp = await client.PostAsync("https://accounts.spotify.com/api/token", content);
string msg = await resp.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<Token>(msg);
return await GetToken(args);
}
public async Task<Token> ExchangeCode(string code)
{
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>
@ -74,7 +67,13 @@ namespace SpotifyAPI.Web.Auth
new KeyValuePair<string, string>("redirect_uri", RedirectUri)
};
HttpClient client = new HttpClient();
return await GetToken(args);
}
private async Task<Token> GetToken(IEnumerable<KeyValuePair<string, string>> args)
{
HttpClientHandler handler = ProxyConfig.CreateClientHandler(ProxyConfig);
HttpClient client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("Authorization", GetAuthHeader());
HttpContent content = new FormUrlEncodedContent(args);