<?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: /token endpoint - CORS Error in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5237150#M2950</link>
    <description>Thanks, yeah this is totally on me. I don't know how I missed that I'm calling an incorrect endpoint &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;Thought that an incorrect endpoint would give some error codes etc, and didn't focus on it so much &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Changed it to the correct endpoint and got it working.</description>
    <pubDate>Tue, 20 Jul 2021 08:52:12 GMT</pubDate>
    <dc:creator>Anent</dc:creator>
    <dc:date>2021-07-20T08:52:12Z</dc:date>
    <item>
      <title>/token endpoint - CORS Error</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5232292#M2837</link>
      <description>&lt;P&gt;&lt;STRONG&gt;My Question or Issue&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When sending an request to: &lt;EM&gt;&lt;A href="https://accounts.spotify.com/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/token&lt;/A&gt;&lt;/EM&gt;&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="markup"&gt;Access to fetch at 'https://accounts.spotify.com/token' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.&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;&lt;STRONG&gt;It would be nice to know if it is intentional to block request coming from the client.&lt;/STRONG&gt;&lt;BR /&gt;I'm creating an svelte package that would handle authentication + wraps the player for the end-user for easy access. It currently handles authentication with PKCE, but sending request from the client will cause these CORS issues. For sake of simplicity for end-users, aimed to have this package client-sided as the Web Playback SDK is fully client-sided.&lt;BR /&gt;&lt;BR /&gt;Code used for fetching:&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;LI-CODE lang="javascript"&gt;  const body: AccessTokenBody = {
    client_id: client,
    grant_type: 'authorization_code',
    code: code,
    redirect_uri: redirect,
    code_verifier: verifier
  }; 
  const response = await fetch(endpoints.token, {
    body: new URLSearchParams(body),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
  });

  if (response.status === 200) {
    const json: AccessTokenResponse = await response.json();
    return json;
  } else {
    console.log('Invalid response while fetcing token!', response.statusText);
  }&lt;/LI-CODE&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;Sidenote:&lt;BR /&gt;I have created an personal react app 1y ago that used PKCE and Web Playback SDK and it worked fully in the client. It seems nothing has changed in the documentation, so has there been an decision to block request from the client?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 11:04:43 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5232292#M2837</guid>
      <dc:creator>Anent</dc:creator>
      <dc:date>2021-07-08T11:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: /token endpoint - CORS Error</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5235210#M2927</link>
      <description>&lt;P&gt;Welcome to the forum,&amp;nbsp;&lt;a href="https://community.spotify.com/t5/user/viewprofilepage/user-id/16847433"&gt;@Anent&lt;/a&gt;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The endpoint for fetching access tokens is&amp;nbsp;&lt;A href="https://accounts.spotify.com/api/token" target="_blank"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;. The error message that you posted shows a slightly different endpoint. Could you double check that you are sending the request to the right URI?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 06:31:31 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5235210#M2927</guid>
      <dc:creator>spotifyjosh</dc:creator>
      <dc:date>2021-07-15T06:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: /token endpoint - CORS Error</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5237150#M2950</link>
      <description>Thanks, yeah this is totally on me. I don't know how I missed that I'm calling an incorrect endpoint &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;Thought that an incorrect endpoint would give some error codes etc, and didn't focus on it so much &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Changed it to the correct endpoint and got it working.</description>
      <pubDate>Tue, 20 Jul 2021 08:52:12 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5237150#M2950</guid>
      <dc:creator>Anent</dc:creator>
      <dc:date>2021-07-20T08:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: /token endpoint - CORS Error</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5237575#M2958</link>
      <description>&lt;P&gt;Great, glad to hear that you were able to solve it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 05:07:01 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/token-endpoint-CORS-Error/m-p/5237575#M2958</guid>
      <dc:creator>spotifyjosh</dc:creator>
      <dc:date>2021-07-21T05:07:01Z</dc:date>
    </item>
  </channel>
</rss>

