mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #1205] Error 401 when requesting current_user_playing_track() #704
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#704
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @HappyTea1 on GitHub (Jun 20, 2025).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1205
Describe the bug
Sows error when trying to show current_user_playing_track(), but works with current_user_saved_tracks()
Both sould use the Auth code flow
Your code
import spotipy
from spotipy.oauth2 import SpotifyOAuth
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(
client_id="CLIENT_ID",
client_secret="CLIENT_SECRET",
redirect_uri="https://spotify.com",
scope="user-library-read"))
result = sp.current_user_playing_track()
print(result)
Expected behavior
Print a json with the information of the track.
Output
HTTP Error for GET to https://api.spotify.com/v1/me/player/currently-playing with Params: {} returned 401 due to Permissions missing
Traceback (most recent call last):
File "C:\Users\name\AppData\Roaming\Python\Python310\site-packages\spotipy\client.py", line 274, in _internal_call
response.raise_for_status()
File "C:\Users\name\AppData\Roaming\Python\Python310\site-packages\requests\models.py", line 1026, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.spotify.com/v1/me/player/currently-playing
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\name\OneDrive\Documents\spotify song player\playerViewer.py", line 11, in
results = sp.current_user_playing_track()
File "C:\Users\name\AppData\Roaming\Python\Python310\site-packages\spotipy\client.py", line 1265, in current_user_playing_track
return self._get("me/player/currently-playing")
File "C:\Users\name\AppData\Roaming\Python\Python310\site-packages\spotipy\client.py", line 324, in _get
return self._internal_call("GET", url, payload, kwargs)
File "C:\Users\name\AppData\Roaming\Python\Python310\site-packages\spotipy\client.py", line 294, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 401, code: -1 - https://api.spotify.com/v1/me/player/currently-playing:
Permissions missing, reason: None
Environment:
Additional context
Verified client id and secret for errors.
@HappyTea1 commented on GitHub (Jun 20, 2025):
Scope not set correctly to user-read-currently-playing