<?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: How to request several scopes for a token to Spotify API in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/How-to-request-several-scopes-for-a-token-to-Spotify-API/m-p/5070420#M1525</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.spotify.com/t5/user/viewprofilepage/user-id/24053759"&gt;@jpmolinamatute&lt;/a&gt;, thanks for reaching out on the Spotify Community!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hmm, the documentation about the client-credentials authorization flow says the following: "&lt;SPAN&gt;However that this flow does not include &lt;/SPAN&gt;authorization&lt;SPAN&gt; and therefore cannot be used to access or to manage a user private data". This means that you can't use that endpoint with the authorization flow that you're using.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you try it with another authorization flow? That should help.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Keep me in loop!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Happy coding,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hubo&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 11:20:00 GMT</pubDate>
    <dc:creator>Hubo</dc:creator>
    <dc:date>2020-11-12T11:20:00Z</dc:date>
    <item>
      <title>How to request several scopes for a token to Spotify API</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/How-to-request-several-scopes-for-a-token-to-Spotify-API/m-p/5069469#M1517</link>
      <description>&lt;P&gt;I need to "authorize" the bearer token to delete some tracks from a list (from my personal Spotify account) I'm following this &lt;A href="https://developer.spotify.com/documentation/general/guides/authorization-guide/#client-credentials-flow" target="_self"&gt;flow&lt;/A&gt; I first make a POST request to &lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/api/token&lt;/A&gt; using `"Authorization: Basic ZjM4ZjAw...WY0MzE="` header and with the desired scope in the body and then another POST request to the actual endpoint with&lt;BR /&gt;`f"Authorization: Bearer {response_dict['access_token']}"` header. Getting these two tokens seems to work without a problem.&lt;/P&gt;&lt;P&gt;I have checked similar question in StackOverflow, but they either not address my problem specifically or they don't have an answer at all&lt;/P&gt;&lt;P&gt;this is my actual python code:&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;cred = f"{environ['SPOTIPY_CLIENT_ID']}:{environ['SPOTIPY_CLIENT_SECRET']}"
cred = cred.encode("ascii")
cred = base64.b64encode(cred)
cred = cred.decode("ascii")

headers = {"Authorization": f"Basic {cred}"}
data = {
    "grant_type": "client_credentials",
    "scope": "playlist-modify-private user-library-read",
}
url = "https://accounts.spotify.com/api/token"
response = requests.post(url, headers=headers, data=data)
if response.status_code != 200:
    raise Exception(response.reason)
    session = requests.Session()
    response_dict = response.json()
    session.headers.update({
        "Content-Type": "application/json",
        "Authorization": f"Bearer {response_dict['access_token']}",
    })&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;&lt;P&gt;then I got the scope in the first response as a "confirmation that they granted" (at least that's my interpretation of seeing the same scope that I request in their response)&lt;/P&gt;&lt;P&gt;**HOWEVER**: when I attempt to delete some tracks I get a 403 error, forbidden to do so &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; When I use the token from &lt;A href="https://developer.spotify.com/console/delete-playlist-tracks/" target="_self"&gt;their site&lt;/A&gt; everything works as expected... any idea what could it be or what am I missing????&lt;/P&gt;&lt;P&gt;thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 16:56:02 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/How-to-request-several-scopes-for-a-token-to-Spotify-API/m-p/5069469#M1517</guid>
      <dc:creator>jpmolinamatute</dc:creator>
      <dc:date>2020-11-10T16:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to request several scopes for a token to Spotify API</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/How-to-request-several-scopes-for-a-token-to-Spotify-API/m-p/5070420#M1525</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.spotify.com/t5/user/viewprofilepage/user-id/24053759"&gt;@jpmolinamatute&lt;/a&gt;, thanks for reaching out on the Spotify Community!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hmm, the documentation about the client-credentials authorization flow says the following: "&lt;SPAN&gt;However that this flow does not include &lt;/SPAN&gt;authorization&lt;SPAN&gt; and therefore cannot be used to access or to manage a user private data". This means that you can't use that endpoint with the authorization flow that you're using.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you try it with another authorization flow? That should help.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Keep me in loop!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Happy coding,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hubo&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 11:20:00 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/How-to-request-several-scopes-for-a-token-to-Spotify-API/m-p/5070420#M1525</guid>
      <dc:creator>Hubo</dc:creator>
      <dc:date>2020-11-12T11:20:00Z</dc:date>
    </item>
  </channel>
</rss>

