<?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 Errors in authorization code flow documentation for refreshing token? in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Errors-in-authorization-code-flow-documentation-for-refreshing/m-p/5386917#M4690</link>
    <description>&lt;P&gt;According to the &lt;A href="https://developer.spotify.com/documentation/general/guides/authorization/code-flow/" target="_self"&gt;authorization code flow&lt;/A&gt; documentation, in order to use a refresh token to receive a new access token we need to POST a request to &lt;A href="https://accounts.spotify.com/api/token" target="_blank"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;&amp;nbsp;with the following fields in the x-www-form-urlencoded body:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;grant_type&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;refresh_token&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;And send an HTTP basic authorization header with the base64 "client_id:client_secret" value. That all translate into something like:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;curl https://accounts.spotify.com/api/token \&lt;BR /&gt;  -d 'grant_type=refresh_token' \&lt;BR /&gt;  -d 'refresh_token=...' \&lt;BR /&gt;  -H "Authorization: Basic $(echo -n "$client_id:$client_secret"|base64 -w0)"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;..but this doesn't appear to work. Following the suggestion of some random person on github, I am able to successfully request a new access token if I get rid of the authorization header and include in the request body:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;grant_type&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;refresh_token&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;client_id&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;client_secret&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;That is:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;curl https://accounts.spotify.com/api/token \&lt;BR /&gt;  -d 'grant_type=refresh_token' \&lt;BR /&gt;  -d 'refresh_token=...' \&lt;BR /&gt;  -d "client_id=$client_id" \&lt;BR /&gt;  -d "client_secret=$client_secret"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is the documentation incorrect? Am I just lucky that the second form of the request works, even though it's not documented?&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 May 2022 01:39:57 GMT</pubDate>
    <dc:creator>larsks</dc:creator>
    <dc:date>2022-05-27T01:39:57Z</dc:date>
    <item>
      <title>Errors in authorization code flow documentation for refreshing token?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Errors-in-authorization-code-flow-documentation-for-refreshing/m-p/5386917#M4690</link>
      <description>&lt;P&gt;According to the &lt;A href="https://developer.spotify.com/documentation/general/guides/authorization/code-flow/" target="_self"&gt;authorization code flow&lt;/A&gt; documentation, in order to use a refresh token to receive a new access token we need to POST a request to &lt;A href="https://accounts.spotify.com/api/token" target="_blank"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;&amp;nbsp;with the following fields in the x-www-form-urlencoded body:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;grant_type&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;refresh_token&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;And send an HTTP basic authorization header with the base64 "client_id:client_secret" value. That all translate into something like:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;curl https://accounts.spotify.com/api/token \&lt;BR /&gt;  -d 'grant_type=refresh_token' \&lt;BR /&gt;  -d 'refresh_token=...' \&lt;BR /&gt;  -H "Authorization: Basic $(echo -n "$client_id:$client_secret"|base64 -w0)"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;..but this doesn't appear to work. Following the suggestion of some random person on github, I am able to successfully request a new access token if I get rid of the authorization header and include in the request body:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;grant_type&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;refresh_token&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;client_id&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;client_secret&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;That is:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;curl https://accounts.spotify.com/api/token \&lt;BR /&gt;  -d 'grant_type=refresh_token' \&lt;BR /&gt;  -d 'refresh_token=...' \&lt;BR /&gt;  -d "client_id=$client_id" \&lt;BR /&gt;  -d "client_secret=$client_secret"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is the documentation incorrect? Am I just lucky that the second form of the request works, even though it's not documented?&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 01:39:57 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Errors-in-authorization-code-flow-documentation-for-refreshing/m-p/5386917#M4690</guid>
      <dc:creator>larsks</dc:creator>
      <dc:date>2022-05-27T01:39:57Z</dc:date>
    </item>
  </channel>
</rss>

