<?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: Server error for user-read-recently-played endpoint in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5860334#M12534</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Ximzend,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I am running it every 30 min it will update, correct?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2024 17:17:49 GMT</pubDate>
    <dc:creator>martinweiss</dc:creator>
    <dc:date>2024-02-02T17:17:49Z</dc:date>
    <item>
      <title>Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5847321#M12487</link>
      <description>&lt;P&gt;I am working on a project using the Spotify API and the&amp;nbsp;&lt;SPAN class=""&gt;user-read-recently-played endpoint. I keep getting&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;{'error': {'status': 500, 'message': 'Server error.'}}. I used the spotipy library with the same endpoint and it worked. When I use requests and try to make a request to that endpoint I get the 500 response. Any help would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 14:29:28 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5847321#M12487</guid>
      <dc:creator>martinweiss</dc:creator>
      <dc:date>2024-01-29T14:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5847813#M12489</link>
      <description>&lt;P&gt;Hi&amp;nbsp;martinweiss,&lt;/P&gt;&lt;P&gt;Can you please post your code as a code-block of you have so far?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 18:40:22 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5847813#M12489</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2024-01-29T18:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5848379#M12494</link>
      <description>&lt;P class=""&gt;Hi. Yes, see below:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;client_id = ''&lt;/P&gt;&lt;P class=""&gt;client_secret = ''&lt;/P&gt;&lt;P class=""&gt;redirect_uri = '&lt;A href="http://localhost:8888/callback" target="_blank" rel="noopener"&gt;http://localhost:8888/callback&lt;/A&gt;'&lt;/P&gt;&lt;P class=""&gt;scope = 'user-read-recently-played'&lt;/P&gt;&lt;P class=""&gt;token_url = '&lt;A href="https://accounts.spotify.com/api/token" target="_blank" rel="noopener"&gt;https://accounts.spotify.com/api/token&lt;/A&gt;'&lt;/P&gt;&lt;P class=""&gt;history_url = '&lt;A href="https://api.spotify.com/v1/me/player/recently-played" target="_blank" rel="noopener"&gt;https://api.spotify.com/v1/me/player/recently-played&lt;/A&gt;'&lt;/P&gt;&lt;P class=""&gt;base64_auth = b64encode(f'{client_id}:{client_secret}'.encode()).decode('utf-8')&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;def get_access_token():&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;headers = {&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;'Authorization': f'Basic {base64_auth}',&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;'Content-Type': 'application/x-www-form-urlencoded',&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;data = {&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;'grant_type': 'client_credentials',&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;'scope': 'user-read-recently-played',&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;response = requests.post(token_url, headers=headers, data=data)&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;STRONG&gt;return&lt;/STRONG&gt; response.json().get('access_token')&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;def get_recently_played(access_token):&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;headers = {&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;'Authorization': f'Bearer {access_token}',&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;response = requests.get(history_url, headers=headers)&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;STRONG&gt;return&lt;/STRONG&gt; response.json()&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;access_token = get_access_token()&lt;/P&gt;&lt;P class=""&gt;recently_played = get_recently_played(access_token)&lt;/P&gt;&lt;P class=""&gt;print(recently_played) # I get&amp;nbsp;&amp;nbsp;{'error': {'status': 500, 'message': 'Server error.'}}&amp;nbsp; &amp;nbsp; here&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Also, what is the life of a refresh token?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 00:17:30 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5848379#M12494</guid>
      <dc:creator>martinweiss</dc:creator>
      <dc:date>2024-01-30T00:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5849244#M12497</link>
      <description>&lt;P&gt;The problem is&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;'grant_type': 'client_credentials'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Since the&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developer.spotify.com/documentation/web-api/tutorials/client-credentials-flow" target="_blank" rel="noopener nofollow noreferrer"&gt;Client Credentials flow&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;does not include authorization, only endpoints that do not access user information can be accessed. Therefore, in this case, you should use a different&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developer.spotify.com/documentation/web-api/concepts/authorization" target="_blank" rel="noopener nofollow noreferrer"&gt;Authorization&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;method that lets you log in.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I don't know the lifetime of a refresh token. You will get a new one if it is expired when you refresh the access token.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 10:37:30 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5849244#M12497</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2024-01-30T10:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5850321#M12502</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Ximzend,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that, so I tried to get a refresh token which I was able to do to get a new access token to make a request which worked. However, the refresh token I used was only able to be used once then I got {"error":"invalid_grant","error_description":"Refresh token revoked"} when I tried to use the same token to get a new access token after 3600 seconds since it had expired. I am looking for a way to generate a refresh token manually every so often as in weeks to update and then use that refresh token to generate a new access token on a schedule such as daily in a scheduled script. How can I generate a refresh token with an extended life and have the permissions to be reused for its lifetime?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 14:33:29 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5850321#M12502</guid>
      <dc:creator>martinweiss</dc:creator>
      <dc:date>2024-01-30T14:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5850506#M12503</link>
      <description>&lt;P&gt;In some cases, you can use the refresh token only once, so you should get a new one after every refresh.&lt;/P&gt;&lt;P&gt;Note: your code doesn't use anything of the Python module &lt;A href="https://github.com/spotipy-dev/spotipy" target="_blank" rel="noopener"&gt;Spotipy&lt;/A&gt;...&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 15:20:55 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5850506#M12503</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2024-01-30T15:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5850616#M12504</link>
      <description>&lt;P&gt;So how can I get a new token after every refresh? I want to run this code on AWS Lambda without the need to have a URL open and have to accept and then get a token. I am willing to do that every so often as every few weeks but I need the script to run very often and authenticate itself on its own. I tried using Spotipy which worked fine locally but the Lambda function cannot authenticate because I cannot open the URL. I also tried on an EC2 to no avail.&amp;nbsp; Any suggestions?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 15:51:30 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5850616#M12504</guid>
      <dc:creator>martinweiss</dc:creator>
      <dc:date>2024-01-30T15:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5850671#M12505</link>
      <description>&lt;P&gt;If you are using Spotipy, you can set the redirect url to the redirect uri of your server, run the script on your PC, and copy over the .cache file. (There's a option in Spotipy that you must copy the resulting URL after login in the console of your PC for the first run).&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 16:20:35 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5850671#M12505</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2024-01-30T16:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5858168#M12523</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Ximzend,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That seemed to work. I took the local .cache file and put it on my EC2. It will continue to update on its own, correct? Thanks for all the help, I appreciate it.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 20:24:19 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5858168#M12523</guid>
      <dc:creator>martinweiss</dc:creator>
      <dc:date>2024-02-01T20:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5859139#M12528</link>
      <description>&lt;P&gt;Yes. But keep in mind that when the script doesn't run for a long while, the refresh token will be too old to renew the access token. I don't know for how long, but it lasts definitely more than a week.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 09:10:25 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5859139#M12528</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2024-02-02T09:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5860334#M12534</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Ximzend,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I am running it every 30 min it will update, correct?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 17:17:49 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5860334#M12534</guid>
      <dc:creator>martinweiss</dc:creator>
      <dc:date>2024-02-02T17:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5860356#M12535</link>
      <description>&lt;P&gt;Yes, definitely. That's a much shorter time period than a week.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 17:30:03 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5860356#M12535</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2024-02-02T17:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Server error for user-read-recently-played endpoint</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5860749#M12537</link>
      <description>&lt;P&gt;Fantastic. Thanks for all the help.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 20:27:01 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Server-error-for-user-read-recently-played-endpoint/m-p/5860749#M12537</guid>
      <dc:creator>martinweiss</dc:creator>
      <dc:date>2024-02-02T20:27:01Z</dc:date>
    </item>
  </channel>
</rss>

