From fb11f0deb7ebe1010db5c42d9523f036dc3e78c1 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 30 Jul 2019 09:54:02 -0700 Subject: [PATCH] Fix missing proxy config in ExchangeCode method (#363) --- SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs b/SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs index 4ca46dc1..e7e24df9 100644 --- a/SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs +++ b/SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs @@ -55,16 +55,9 @@ namespace SpotifyAPI.Web.Auth new KeyValuePair("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(msg); + return await GetToken(args); } + public async Task ExchangeCode(string code) { List> args = new List> @@ -74,7 +67,13 @@ namespace SpotifyAPI.Web.Auth new KeyValuePair("redirect_uri", RedirectUri) }; - HttpClient client = new HttpClient(); + return await GetToken(args); + } + + private async Task GetToken(IEnumerable> args) + { + HttpClientHandler handler = ProxyConfig.CreateClientHandler(ProxyConfig); + HttpClient client = new HttpClient(handler); client.DefaultRequestHeaders.Add("Authorization", GetAuthHeader()); HttpContent content = new FormUrlEncodedContent(args);