<?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: 400 Bad Request - Access Token - PKCE Auth Code Flow in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/6300743#M14897</link>
    <description>&lt;P data-unlink="true"&gt;&lt;SPAN class=""&gt;Bryan-BC's solution&lt;/SPAN&gt;&amp;nbsp;didn't work for me, unfortunately.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Aug 2024 19:52:20 GMT</pubDate>
    <dc:creator>_camden</dc:creator>
    <dc:date>2024-08-29T19:52:20Z</dc:date>
    <item>
      <title>400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5368013#M4385</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I'm currently on Step 2 (Requesting Access Token) of the &lt;A href="https://developer.spotify.com/documentation/general/guides/authorization/code-flow/" target="_self"&gt;Auth Code Flow&lt;/A&gt; using PKCE, but I am unable to retrieve the access token.&lt;BR /&gt;&lt;STRONG&gt;Problem&lt;/STRONG&gt;&lt;BR /&gt;I am receiving a 400 Bad Request when sending my POST request to the &lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/api/token&lt;/A&gt; endpoint.&lt;BR /&gt;&lt;STRONG&gt;Code Snippet&lt;/STRONG&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Code" style="width: 999px;"&gt;&lt;img src="https://community.spotify.com/t5/image/serverpage/image-id/139901i6833083A29892BF3/image-size/large?v=v2&amp;amp;px=999" role="button" title="tfJWqRc" alt="Code" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Everything seems correct when I output to the console, but it seems like I'm missing something.&lt;BR /&gt;Please help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Edit:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;To make it easier to check my work I will reference the Auth Code Flow documentation here and where that can be found in my code (above).&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Making a POST request to the /api/token endpoint:&lt;BR /&gt;- options.method = "POST"&lt;BR /&gt;- SPOTIFY_TOKEN_ENDPOINT = "&lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;"&lt;/LI&gt;&lt;LI&gt;Request body should contain the parameters in application/x-www-form-urlencoded:&lt;BR /&gt;- headers["Content-Type"] = "application/x-www-form-urlencoded"&lt;BR /&gt;- bodyObject = parameters needed&lt;BR /&gt;&amp;nbsp; searchParams = URLSearchParams object containing parameters and values&lt;BR /&gt;&amp;nbsp; requestBody = bodyObject in x-www-form-urlencoded form&lt;BR /&gt;- request.write(requestBody) = request sending parameters in the body in x-www-form-urlencoded form&lt;/LI&gt;&lt;LI&gt;Request body parameters needed (found in bodyObject):&lt;BR /&gt;- grant_type = "authorization_code"&lt;BR /&gt;- code = codeVal, the code value found in the URL when redirected after Authorization&lt;BR /&gt;- redirect_uri = redirectURI, the same URI sent in Step 1 of Auth Code Flow&lt;BR /&gt;- client_id = environment variable that is expanded at runtime using dotenv library&lt;BR /&gt;- code_verifier = codeVerifier, the code verifier my website created and sent in Step 1 of Auth Code Flow (have confirmed these match)&lt;/LI&gt;&lt;LI&gt;HTTP Headers:&lt;BR /&gt;- headers.Authorization = base64 encoded(&amp;lt;client_id environment variable&amp;gt;:&amp;lt;client_secret environment variable&amp;gt;)&lt;BR /&gt;- headers["Content-Type"] = "application/x-www-form-urlencoded"&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 15 Apr 2022 20:59:05 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5368013#M4385</guid>
      <dc:creator>dm17</dc:creator>
      <dc:date>2022-04-15T20:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5498253#M7828</link>
      <description>&lt;P&gt;same issue. did you figure it out?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 22:42:27 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5498253#M7828</guid>
      <dc:creator>mikemgg123</dc:creator>
      <dc:date>2023-02-01T22:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5503443#M7939</link>
      <description>&lt;P&gt;I have the same problem when trying to refresh my token.&lt;BR /&gt;I'm sending a POST-request to endpoint "&lt;A href="https://accounts.spotify.com/api/token&amp;quot;" target="_blank"&gt;https://accounts.spotify.com/api/token"&lt;/A&gt; and getting 400 "Invalid request". No error message. I just don't get what the problem is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Payload:&lt;BR /&gt;{&lt;BR /&gt;"refresh_token": [my refresh token],&lt;BR /&gt;"grant_type": "refresh_token",&lt;BR /&gt;"client_id": "[my client id]"&lt;BR /&gt;}&lt;BR /&gt;Headers.&lt;BR /&gt;{&lt;BR /&gt;"Content-Type": "application/x-www-form-urlencoded"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 23:02:49 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5503443#M7939</guid>
      <dc:creator>deeema</dc:creator>
      <dc:date>2023-02-10T23:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5601994#M9765</link>
      <description>&lt;P&gt;Are you able to fetch the auth_token the first time around? I have the same issue and keep getting invalid code_verifier when it is exactly the same as generated. Happy to pair program if you’d like, 2 pairs of eyes &amp;gt; one&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 14:11:37 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5601994#M9765</guid>
      <dc:creator>hiftikha</dc:creator>
      <dc:date>2023-06-28T14:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5601995#M9766</link>
      <description>&lt;P&gt;Did you get a successful auth token the first time around using PKCE?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 14:12:23 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5601995#M9766</guid>
      <dc:creator>hiftikha</dc:creator>
      <dc:date>2023-06-28T14:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5603161#M9806</link>
      <description>&lt;P&gt;Any news on this? i kinda have the same issue. Everything was working perfectly fine and out of nowhere i always get TIMEDOUT on&amp;nbsp;&lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener nofollow noreferrer"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 21:53:47 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5603161#M9806</guid>
      <dc:creator>SemyD</dc:creator>
      <dc:date>2023-06-30T21:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5671609#M11444</link>
      <description>&lt;P&gt;I've run into the same issue and wondering if there has been any update?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 00:44:17 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5671609#M11444</guid>
      <dc:creator>rentzy</dc:creator>
      <dc:date>2023-11-13T00:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5850240#M12501</link>
      <description>&lt;P&gt;Just putting this for future devs; I was able to make it work by changing "Content-Type" to "content-type"&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 14:20:43 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/5850240#M12501</guid>
      <dc:creator>Bryan-BC</dc:creator>
      <dc:date>2024-01-30T14:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/6300742#M14896</link>
      <description>&lt;P&gt;Did you solve this problem?&lt;BR /&gt;&lt;BR /&gt;If not, is the line "&lt;SPAN&gt;- headers.Authorization = base64 encoded(&amp;lt;client_id environment variable&amp;gt;:&amp;lt;client_secret environment variable&amp;gt;)" necessary in your headers?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Separately, I'm also having this problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 19:49:59 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/6300742#M14896</guid>
      <dc:creator>_camden</dc:creator>
      <dc:date>2024-08-29T19:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/6300743#M14897</link>
      <description>&lt;P data-unlink="true"&gt;&lt;SPAN class=""&gt;Bryan-BC's solution&lt;/SPAN&gt;&amp;nbsp;didn't work for me, unfortunately.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 19:52:20 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/6300743#M14897</guid>
      <dc:creator>_camden</dc:creator>
      <dc:date>2024-08-29T19:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: 400 Bad Request - Access Token - PKCE Auth Code Flow</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/6491456#M15462</link>
      <description>&lt;P&gt;Same, Bryan solution didn't work either. Any further clue from someone?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2024 08:52:45 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/400-Bad-Request-Access-Token-PKCE-Auth-Code-Flow/m-p/6491456#M15462</guid>
      <dc:creator>Soch</dc:creator>
      <dc:date>2024-11-08T08:52:45Z</dc:date>
    </item>
  </channel>
</rss>

