<?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: 403 Error - Get User's Top Items in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638272#M10781</link>
    <description>&lt;P&gt;Which endpoints do work, and did you get an Access Token with the right scopes?&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2023 08:29:08 GMT</pubDate>
    <dc:creator>Ximzend</dc:creator>
    <dc:date>2023-09-19T08:29:08Z</dc:date>
    <item>
      <title>403 Error - Get User's Top Items</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638180#M10779</link>
      <description>&lt;P&gt;I'm trying to retrieve user's top items from the API but getting a 403 error, other API calls to Spotify are working so my authentication seems fine, my scope is consistent with the documentation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a code screenshot and an example error, does anyone know what I'm doing 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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;async function getUsersTopItems() {
    console.log("access token in function: ", access_token);
    let headerParameters = {
      method: "GET",
      headers: {
        "Content-Type": "application/json",
        Authorization: "Bearer " + access_token,
      },
    };

    console.log("header params: ", headerParameters);

    try {
      const response = await fetch(
        "https://api.spotify.com/v1/me/top/artists",
        headerParameters
      );

      console.log("response: ", response);

      if (!response.ok) {
        const errorData = await response.json();
        console.error("API request failed with status:", response.status);
        console.error("Error details:", errorData);
        return;
      }

      const data = await response.json();
      console.log("artist data: ", data);
      console.log("artistID: ", artistID);
    } catch (error) {
      console.error("Error fetching data:", 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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delarue_0-1695099563730.png" style="width: 400px;"&gt;&lt;img src="https://community.spotify.com/t5/image/serverpage/image-id/162750iCECC176C0DB59983/image-size/medium?v=v2&amp;amp;px=400" role="button" title="delarue_0-1695099563730.png" alt="delarue_0-1695099563730.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 05:00:28 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638180#M10779</guid>
      <dc:creator>delarue</dc:creator>
      <dc:date>2023-09-19T05:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: 403 Error - Get User's Top Items</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638272#M10781</link>
      <description>&lt;P&gt;Which endpoints do work, and did you get an Access Token with the right scopes?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 08:29:08 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638272#M10781</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2023-09-19T08:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: 403 Error - Get User's Top Items</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638275#M10782</link>
      <description>Searching for artists is an example of one that works.&lt;BR /&gt;&lt;BR /&gt;I get an access token back, I didn't see the scopes returned but I will&lt;BR /&gt;check later.&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Sep 2023 09:17:57 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638275#M10782</guid>
      <dc:creator>delarue</dc:creator>
      <dc:date>2023-09-19T09:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: 403 Error - Get User's Top Items</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638294#M10783</link>
      <description>&lt;P&gt;The code yiu are using you've got through the Client Credentials Flow. "Since &lt;A href="https://developer.spotify.com/documentation/web-api/tutorials/client-credentials-flow" target="_blank" rel="noopener"&gt;this flow&lt;/A&gt; does not include authorization, only endpoints that do not access user information can be accessed."&lt;/P&gt;&lt;P&gt;You should choose another way of &lt;A href="https://developer.spotify.com/documentation/web-api/concepts/authorization" target="_blank" rel="noopener"&gt;Authorization&lt;/A&gt;&amp;nbsp;that lets you login and get an access token.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 10:10:43 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/403-Error-Get-User-s-Top-Items/m-p/5638294#M10783</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2023-09-19T10:10:43Z</dc:date>
    </item>
  </channel>
</rss>

