<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Call to https://accounts.spotify.com/api/token no longer working in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Call-to-https-accounts-spotify-com-api-token-no-longer-working/m-p/5603637#M9823</link>
    <description>&lt;P&gt;You are missing the ContentType header.&lt;/P&gt;&lt;P&gt;The following code should work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using var client = new HttpClient();&lt;BR /&gt;client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{clientId}:{clientSecret}")));&lt;/P&gt;&lt;P&gt;var formData = new Dictionary&amp;lt;string, string&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;{ "grant_type", "client_credentials" }&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var content = new FormUrlEncodedContent(formData);&lt;BR /&gt;content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");&lt;/P&gt;&lt;P&gt;var response = await client.PostAsync("&lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;", content);&lt;/P&gt;&lt;P&gt;var responseContent = await response.Content.ReadAsStringAsync();&lt;/P&gt;</description>
    <pubDate>Sun, 02 Jul 2023 08:54:18 GMT</pubDate>
    <dc:creator>Ximzend</dc:creator>
    <dc:date>2023-07-02T08:54:18Z</dc:date>
    <item>
      <title>Call to https://accounts.spotify.com/api/token no longer working</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Call-to-https-accounts-spotify-com-api-token-no-longer-working/m-p/5603608#M9813</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Plan&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Premium&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Country&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;United States&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Question or Issue&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Using the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{clientId}:{clientSecret}")));

var formData = new Dictionary&amp;lt;string, string&amp;gt;
{
{ "grant_type", "client_credentials" }
};

var response = await client.PostAsync("https://accounts.spotify.com/api/token", new FormUrlEncodedContent(formData)); // FAILS HERE

var content = await response.Content.ReadAsStringAsync();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can no longer get an access token to make other API calls... This just stopped working out of nowhere with no code changes, and the application just stops when it tries to execute the marked point in the code. I also attempted to wrap that part of the code in a try/catch and still no helpful exceptions (I assume due to the async nature?)... Any thoughts? I was running different versions of my code back and forth to try and figure out why one version was working and one wasn't, but then when the version that had been working this whole time stopped working... Started to scratch my head. Any thoughts?&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2023 04:37:00 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Call-to-https-accounts-spotify-com-api-token-no-longer-working/m-p/5603608#M9813</guid>
      <dc:creator>Kevinw778</dc:creator>
      <dc:date>2023-07-02T04:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Call to https://accounts.spotify.com/api/token no longer working</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Call-to-https-accounts-spotify-com-api-token-no-longer-working/m-p/5603637#M9823</link>
      <description>&lt;P&gt;You are missing the ContentType header.&lt;/P&gt;&lt;P&gt;The following code should work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using var client = new HttpClient();&lt;BR /&gt;client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($"{clientId}:{clientSecret}")));&lt;/P&gt;&lt;P&gt;var formData = new Dictionary&amp;lt;string, string&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;{ "grant_type", "client_credentials" }&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var content = new FormUrlEncodedContent(formData);&lt;BR /&gt;content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");&lt;/P&gt;&lt;P&gt;var response = await client.PostAsync("&lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;", content);&lt;/P&gt;&lt;P&gt;var responseContent = await response.Content.ReadAsStringAsync();&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2023 08:54:18 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Call-to-https-accounts-spotify-com-api-token-no-longer-working/m-p/5603637#M9823</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2023-07-02T08:54:18Z</dc:date>
    </item>
  </channel>
</rss>

