public static SpotifyAccessCredentials Authorise(SpotifyApplicationcredentials AppCreds)
 {
     SpotifyAccessCredentials credentials = null;
     using (var client = new HttpClient())
     {
         client.BaseAddress = BaseAddress;
         var content = new FormUrlEncodedContent(new[]
         {
             new KeyValuePair<string, string>("grant_type", "authorization_code"),
             new KeyValuePair<string, string>("code", AppCreds.Code),
             new KeyValuePair<string, string>("redirect_uri", AppCreds.RedirectURL)
         });
         client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(
             "Basic", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(
                 string.Format("{0}:{1}", AppCreds.ClientID, AppCreds.ClientSecret))));
         try
         {
             var post = client.PostAsync("/api/token", content);
             post.Wait();
             HttpResponseMessage response = post.Result;
             if (response.StatusCode == HttpStatusCode.OK)
             {
                 var jsonstring = response.Content.ReadAsStringAsync();
                 jsonstring.Wait();
                 string jstring = jsonstring.Result;
                 credentials = JsonConvert.DeserializeObject<SpotifyAccessCredentials>(jstring);
             }
         }
         catch (Exception e)
         {
             throw;
         }
     }
     return credentials;
 }
        public static SpotifyAccessCredentials Authorise(SpotifyApplicationcredentials AppCreds)
        {
            SpotifyAccessCredentials credentials = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = BaseAddress;
                var content = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("grant_type", "authorization_code"),
                    new KeyValuePair <string, string>("code", AppCreds.Code),
                    new KeyValuePair <string, string>("redirect_uri", AppCreds.RedirectURL)
                });
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(
                    "Basic", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(
                                                        string.Format("{0}:{1}", AppCreds.ClientID, AppCreds.ClientSecret))));
                try
                {
                    var post = client.PostAsync("/api/token", content);
                    post.Wait();
                    HttpResponseMessage response = post.Result;
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        var jsonstring = response.Content.ReadAsStringAsync();
                        jsonstring.Wait();
                        string jstring = jsonstring.Result;
                        credentials = JsonConvert.DeserializeObject <SpotifyAccessCredentials>(jstring);
                    }
                }
                catch (Exception e)
                {
                    throw;
                }
            }
            return(credentials);
        }