<?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: Unauthorized Error on Get Current User Data in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Unauthorized-Error-on-Get-Current-User-Data/m-p/5724352#M11760</link>
    <description>&lt;P&gt;Since the &lt;A href="https://developer.spotify.com/documentation/web-api/tutorials/client-credentials-flow" target="_blank" rel="noopener"&gt;Client Credentials flow&lt;/A&gt; does not include authorization, only endpoints that do not access user information can be accessed. Therefore, in this case, you should use a different &lt;A href="https://developer.spotify.com/documentation/web-api/concepts/authorization" target="_blank" rel="noopener"&gt;Authorization&lt;/A&gt; method that lets you log in.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Dec 2023 11:25:24 GMT</pubDate>
    <dc:creator>Ximzend</dc:creator>
    <dc:date>2023-12-04T11:25:24Z</dc:date>
    <item>
      <title>Unauthorized Error on Get Current User Data</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Unauthorized-Error-on-Get-Current-User-Data/m-p/5724087#M11757</link>
      <description>&lt;P&gt;My auth code to get auth token:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;const requestAuthToken = async () =&amp;gt; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;await fetch("&lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;", &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{ body: `grant_type=client_credentials&amp;amp;client_id=${CLIENT_ID}&amp;amp;client_secret=${CLIENT_SECRET}`, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;headers: { "Content-Type": "application/x-www-form-urlencoded", }, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;method: "POST", }) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.then((response) =&amp;gt; response.json()) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.then((data) =&amp;gt; { setAuthToken(data.access_token);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;navigate("/home");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;}) };&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is code that fetchs data from /me api:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;const getUserData = async (token: string) =&amp;gt; {&lt;/P&gt;&lt;P&gt;await fetch("&lt;A href="https://api.spotify.com/v1/me" target="_blank" rel="noopener"&gt;https://api.spotify.com/v1/me&lt;/A&gt;",&lt;/P&gt;&lt;P&gt;{ headers: { Authorization: "Bearer " + token, } })&lt;/P&gt;&lt;P&gt;.then((response) =&amp;gt; response.json())&lt;/P&gt;&lt;P&gt;.then((data) =&amp;gt; {&lt;/P&gt;&lt;P&gt;console.log(data);&lt;/P&gt;&lt;P&gt;setUser(User.fromJSON(data)); })&lt;/P&gt;&lt;P&gt;.catch((error) =&amp;gt; { console.log(error); }); }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The auth function is working so I can get the auth token and save it. But when I try to get users data it is returning 401 Unauthorized.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 08:02:08 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Unauthorized-Error-on-Get-Current-User-Data/m-p/5724087#M11757</guid>
      <dc:creator>mbattaloglu</dc:creator>
      <dc:date>2023-12-04T08:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Unauthorized Error on Get Current User Data</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Unauthorized-Error-on-Get-Current-User-Data/m-p/5724352#M11760</link>
      <description>&lt;P&gt;Since the &lt;A href="https://developer.spotify.com/documentation/web-api/tutorials/client-credentials-flow" target="_blank" rel="noopener"&gt;Client Credentials flow&lt;/A&gt; does not include authorization, only endpoints that do not access user information can be accessed. Therefore, in this case, you should use a different &lt;A href="https://developer.spotify.com/documentation/web-api/concepts/authorization" target="_blank" rel="noopener"&gt;Authorization&lt;/A&gt; method that lets you log in.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2023 11:25:24 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Unauthorized-Error-on-Get-Current-User-Data/m-p/5724352#M11760</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2023-12-04T11:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Unauthorized Error on Get Current User Data</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Unauthorized-Error-on-Get-Current-User-Data/m-p/5742196#M11851</link>
      <description>&lt;P&gt;Problem is solved. Here is the Stack Overflow post:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/77598436/spotify-web-api-401-unauthorized" target="_blank"&gt;https://stackoverflow.com/questions/77598436/spotify-web-api-401-unauthorized&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 06:26:51 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Unauthorized-Error-on-Get-Current-User-Data/m-p/5742196#M11851</guid>
      <dc:creator>mbattaloglu</dc:creator>
      <dc:date>2023-12-12T06:26:51Z</dc:date>
    </item>
  </channel>
</rss>

