From ba03526f199add5b69a60e4dcb6d89f16c7b0301 Mon Sep 17 00:00:00 2001 From: "Henning M. Stephansen" Date: Thu, 9 Mar 2017 21:58:48 +0100 Subject: [PATCH] #134 Adds User-Agent in the OAuth request due to recent changes in the Spotify API --- SpotifyAPI/Local/RemoteHandler.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/SpotifyAPI/Local/RemoteHandler.cs b/SpotifyAPI/Local/RemoteHandler.cs index d9d6f9ef..fa1eac03 100644 --- a/SpotifyAPI/Local/RemoteHandler.cs +++ b/SpotifyAPI/Local/RemoteHandler.cs @@ -60,7 +60,7 @@ namespace SpotifyAPI.Local internal string GetOAuthKey() { string raw; - using (WebClient wc = new WebClient()) + using (WebClient wc = GetWebClientWithUserAgentHeader()) { raw = wc.DownloadString("http://open.spotify.com/token"); } @@ -166,5 +166,14 @@ namespace SpotifyAPI.Local { return Convert.ToInt32((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds); } + + internal WebClient GetWebClientWithUserAgentHeader() + { + var wc = new WebClient(); + + wc.Headers.Add(HttpRequestHeader.UserAgent, "Spotify (1.0.50.41368.gbd68dbef)"); + + return wc; + } } } \ No newline at end of file