<?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: Why is refreshing access token returning &amp;quot;invalid client&amp;quot;? in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5451113#M6868</link>
    <description>&lt;P&gt;Hi! What was the error in your code that was causing the problem? I'm having the same problem and my code is similar to yours.&lt;/P&gt;</description>
    <pubDate>Sat, 29 Oct 2022 05:43:43 GMT</pubDate>
    <dc:creator>kyds3k</dc:creator>
    <dc:date>2022-10-29T05:43:43Z</dc:date>
    <item>
      <title>Why is refreshing access token returning "invalid client"?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5270504#M3337</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;UK&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Device&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Edge browser&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Operating System&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;windows 10&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;I always receive this error when I run my fetch call to refresh my access_token: {error: 'invalid_client', error_description: 'Invalid client'}&lt;/P&gt;&lt;P&gt;I have checked my client id and secret and the refresh token being passed in is correct. I feel something must be incorrect about my refreshAccessToken() fetch function but I'm not sure what is wrong?&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const refreshAccessToken = () =&amp;gt; {
    console.log("run refresh: " + refreshToken);
    if (refreshToken !== "") {
      console.log("refresh token: ", refreshToken);
      console.log("refreshAccessToken running fetch");
      fetch("https://accounts.spotify.com/api/token", {
        method: "POST",
        body: new URLSearchParams({
          refresh_token: refreshToken,
          grant_type: "refresh_token",
        }),
        headers: {
          Authorization:
            "Basic " +
            Buffer.from(
              spotify_client_id + ":" + spotify_client_secret
            ).toString("base64"),
          "Content-Type": "application/x-www-form-urlencoded",
        },
      })
        .then((response) =&amp;gt; response.json())
        .then((data) =&amp;gt; {
          if (data.error) {
            console.log("returned data error: ", data);
            return;
          }
          console.log("returned data: ", data);
          setToken(data.access_token);
          //setExpiresIn(data.expires_in);
        })
        .catch((error) =&amp;gt; console.log("refresh token error: ", error));
    }
  };&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;&amp;nbsp;&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;</description>
      <pubDate>Sun, 03 Oct 2021 16:41:26 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5270504#M3337</guid>
      <dc:creator>Jingojango</dc:creator>
      <dc:date>2021-10-03T16:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why is refreshing access token returning "invalid client"?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5270887#M3340</link>
      <description>&lt;P&gt;I think you may have discovered a bug in our authorization documentation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you exchange the code for an access token you get a few different parameters returned - access_token, token_type, scope, expires_in and &lt;STRONG&gt;refresh_token.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;From the docs:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;A token that can be sent to the Spotify Accounts service in place of an authorization code. (When the access code expires, send a POST request to the Accounts service /api/token endpoint, but use this code in place of an authorization code. A new access token will be returned. A new refresh token might be returned too.)&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try sending the refresh_token as the value for the Authorization header instead and let me know if that works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know the docs just below this says to send base64 encoded client_id:client_secret, but at least from the PKCE flow you have to use the refresh_token instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know how it works and we'll get the docs updated accordingly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 12:47:46 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5270887#M3340</guid>
      <dc:creator>ohej</dc:creator>
      <dc:date>2021-10-04T12:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why is refreshing access token returning "invalid client"?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5272145#M3359</link>
      <description>&lt;P&gt;Are you using the PKCE flow or code flow?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 14:08:46 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5272145#M3359</guid>
      <dc:creator>ohej</dc:creator>
      <dc:date>2021-10-06T14:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why is refreshing access token returning "invalid client"?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5272284#M3361</link>
      <description>Never mind. It was a problem with my code elsewhere. how do i close/delete my post?</description>
      <pubDate>Wed, 06 Oct 2021 15:31:52 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5272284#M3361</guid>
      <dc:creator>Jingojango</dc:creator>
      <dc:date>2021-10-06T15:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why is refreshing access token returning "invalid client"?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5451113#M6868</link>
      <description>&lt;P&gt;Hi! What was the error in your code that was causing the problem? I'm having the same problem and my code is similar to yours.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 05:43:43 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5451113#M6868</guid>
      <dc:creator>kyds3k</dc:creator>
      <dc:date>2022-10-29T05:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why is refreshing access token returning "invalid client"?</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5610703#M10025</link>
      <description>&lt;P&gt;Did you end up fixing it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 17:53:34 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Why-is-refreshing-access-token-returning-quot-invalid-client/m-p/5610703#M10025</guid>
      <dc:creator>Gflex39</dc:creator>
      <dc:date>2023-07-17T17:53:34Z</dc:date>
    </item>
  </channel>
</rss>

