Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Can't get users recently played after following the authorization process user-read-recently-played

Solved!

Can't get users recently played after following the authorization process user-read-recently-played

Hi All, 

 

After following the authorization process 'user-read-recently-played' and checking in my personal account if it worked, I still can't retrieve my recently played tracks. It seems to be an authorization problem, as I can retrieve the user profile info. Below I'll provide you with my authorization code, followed by my code to retrieve the 50 past tracks and my error message. Really hope you can help! Many thanks in advance.

 

*********** I used the below code to get the authorization: 

client_id = "my_id"
redirect_uri = "my_redirect"
scopes = "user-read-recently-played" 
show_dialog = "true" 

 

# Build the request URL
url = f"https://accounts.spotify.com/authorize?client_id={client_id}&response_type=code&redirect_uri={redire...}"

# Make the GET request
response = requests.get(url)

# Print the response
print(response.url)

 

********* And my code to get the 50 last tracks:

gebruikers_id = '{my_id}'
url = f'https://api.spotify.com/v1/users/{gebruikers_id}/player/recently-played'

parameters = {
'limit': 50
}


headers = {
'Authorization': f'Bearer {access_token}'
}


response = requests.get(url, headers=headers, params=parameters)


if response.status_code == 200:
print("Verzoek succesvol:")
print(response.json())
else:
print("Fout bij het verzoek:")
print(response.status_code, response.text)

print(response)

 

 

*************My errorcode: 

404 {
  "error": {
    "status": 404,
    "message": "Service not found"
  }
}
<Response [404]>

 

Reply

Accepted Solutions
Marked as solution

The URL for the endpoint is: https://api.spotify.com/v1/me/player/recently-played

So, without a user ID.

Also, you can only get the recently played tracks from the authenticated user.

View solution in original post

Marked as solution

Also, you need the code from this Stack Overflow answer for the authorization code flow.

It isn't just one simple get request.

View solution in original post

4 Replies

For some reason my link was shortened in the post. To clarify, my full request authorization link was:

f"https://accounts.spotify.com/authorize?client_id={client_id}&response_type=code&redirect_uri={redire...}"

Marked as solution

The URL for the endpoint is: https://api.spotify.com/v1/me/player/recently-played

So, without a user ID.

Also, you can only get the recently played tracks from the authenticated user.

Marked as solution

Also, you need the code from this Stack Overflow answer for the authorization code flow.

It isn't just one simple get request.

Thanks so much for your quick reply! It works now. 

Suggested posts