[GH-ISSUE #445] Server Error with next_track #260

Closed
opened 2026-02-27 23:21:40 +03:00 by kerem · 8 comments
Owner

Originally created by @AphroMad on GitHub (Feb 25, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/445

Hi !
First, i wanted to say that i just love this python API so thank you so much guys for working on it !

Second, here is my problem, i try to use the next_track function and sometimes, there is this message :
SpotifyException: https://api.spotify.com/v1/me/player/next:
Server error.

When i click on the link of the error, there is this :

{ "error": { "status": 401, "message": "No token provided" } }

Which i don't understand why because, here is the part of my code where i use the function

error next_track

And you can see that there is a token.

The thing i don't understand is : sometimes it works perfectly, and then maybe 2 or 3 times later, even if i don't change my code, there is this error

Thank you for your future helping and your time !

Ps : Here is the code if you wanna try :

import spotipy
import spotipy.util as util

def connexion(username) :

clientID = "000000000000"
clientsecret = "0000000000000000" # those 2 are fake code for you but i have one that works :) 
scope='streaming'

token = util.prompt_for_user_token(username,
                           scope,
                           client_id=clientID,
                           client_secret=clientsecret,
                           redirect_uri="http://google.com/")
     
# création of spotify object
spotifyObject = spotipy.Spotify(auth=token)

return(spotifyObject)

user = "test" # fake name too
objet = connexion(user)
objet.next_track()

Originally created by @AphroMad on GitHub (Feb 25, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/445 Hi ! First, i wanted to say that i just love this python API so thank you so much guys for working on it ! Second, here is my problem, i try to use the next_track function and sometimes, there is this message : SpotifyException: https://api.spotify.com/v1/me/player/next: Server error. When i click on the link of the error, there is this : `{ "error": { "status": 401, "message": "No token provided" } }` Which i don't understand why because, here is the part of my code where i use the function ![error next_track](https://user-images.githubusercontent.com/51882862/75273472-396edd80-5801-11ea-9037-2cec3496ef26.JPG) And you can see that there is a token. The thing i don't understand is : sometimes it works perfectly, and then maybe 2 or 3 times later, even if i don't change my code, there is this error Thank you for your future helping and your time ! Ps : Here is the code if you wanna try : import spotipy import spotipy.util as util def connexion(username) : clientID = "000000000000" clientsecret = "0000000000000000" # those 2 are fake code for you but i have one that works :) scope='streaming' token = util.prompt_for_user_token(username, scope, client_id=clientID, client_secret=clientsecret, redirect_uri="http://google.com/") # création of spotify object spotifyObject = spotipy.Spotify(auth=token) return(spotifyObject) user = "test" # fake name too objet = connexion(user) objet.next_track()
kerem closed this issue 2026-02-27 23:21:40 +03:00
Author
Owner

@KGB33 commented on GitHub (Feb 25, 2020):

Can you add your python traceback for the error? Does the error always occur on line 35 in that file?

<!-- gh-comment-id:590995632 --> @KGB33 commented on GitHub (Feb 25, 2020): Can you add your python traceback for the error? Does the error always occur on line 35 in that file?
Author
Owner

@AphroMad commented on GitHub (Feb 25, 2020):

Can you add your python traceback for the error? Does the error always occur on line 35 in that file?

This is a part of a file, i the entire code, the line : objet.next_track() is 161 but yes, the error is always here

I tried to change next_track() by pause_playback() and some times there is an error too

here is the traceback :

Traceback (most recent call last):

File "", line 1, in
runfile('D:/Prog&Job/Business/En cours/Spotify Bot/Spotify_bot.py', wdir='D:/Prog&Job/Business/En cours/Spotify Bot')

File "C:\Users\pierr\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "C:\Users\pierr\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/Prog&Job/Business/En cours/Spotify Bot/Spotify_bot.py", line 161, in
objet.next_track()

File "C:\Users\pierr\Anaconda3\lib\site-packages\spotipy\client.py", line 1229, in next_track
return self._post(self._append_device_id("me/player/next", device_id))

File "C:\Users\pierr\Anaconda3\lib\site-packages\spotipy\client.py", line 227, in _post
return self._internal_call("POST", url, payload, kwargs)

File "C:\Users\pierr\Anaconda3\lib\site-packages\spotipy\client.py", line 173, in _internal_call
headers=r.headers,

SpotifyException: https://api.spotify.com/v1/me/player/next:
Server error.

<!-- gh-comment-id:591001622 --> @AphroMad commented on GitHub (Feb 25, 2020): > Can you add your python traceback for the error? Does the error always occur on line 35 in that file? This is a part of a file, i the entire code, the line : objet.next_track() is 161 but yes, the error is always here I tried to change next_track() by pause_playback() and some times there is an error too here is the traceback : Traceback (most recent call last): File "<ipython-input-2-e6d8f85ffc34>", line 1, in <module> runfile('D:/Prog&Job/Business/En cours/Spotify Bot/Spotify_bot.py', wdir='D:/Prog&Job/Business/En cours/Spotify Bot') File "C:\Users\pierr\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "C:\Users\pierr\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "D:/Prog&Job/Business/En cours/Spotify Bot/Spotify_bot.py", line 161, in <module> objet.next_track() File "C:\Users\pierr\Anaconda3\lib\site-packages\spotipy\client.py", line 1229, in next_track return self._post(self._append_device_id("me/player/next", device_id)) File "C:\Users\pierr\Anaconda3\lib\site-packages\spotipy\client.py", line 227, in _post return self._internal_call("POST", url, payload, kwargs) File "C:\Users\pierr\Anaconda3\lib\site-packages\spotipy\client.py", line 173, in _internal_call headers=r.headers, SpotifyException: https://api.spotify.com/v1/me/player/next: Server error.
Author
Owner

@KGB33 commented on GitHub (Feb 25, 2020):

The code you've posted should work...

Maybe you are re-initializing "objet" without the token? Can you share the rest of your code via Pastebin?

<!-- gh-comment-id:591017422 --> @KGB33 commented on GitHub (Feb 25, 2020): The code you've posted should work... Maybe you are re-initializing "objet" without the token? Can you share the rest of your code via [Pastebin](https://pastebin.com/)?
Author
Owner

@AphroMad commented on GitHub (Feb 25, 2020):

When i re-initialize "objet", i use the connexion function, and in this function i call the token...

i've to try an other to way to do it tonight, and i'll keep you in touch if the problem is still here !

but thanks anyway :)

<!-- gh-comment-id:591019758 --> @AphroMad commented on GitHub (Feb 25, 2020): When i re-initialize "objet", i use the connexion function, and in this function i call the token... i've to try an other to way to do it tonight, and i'll keep you in touch if the problem is still here ! but thanks anyway :)
Author
Owner

@AphroMad commented on GitHub (Feb 26, 2020):

Theeeen, now it work but there is an other problem xD

i don't know if we can do it but is it possible to connect multiple accounts with the API ?
and if yes, how can i switch the action ?

Like, i want account A play this music et account B playing this one

Is this possible ?

<!-- gh-comment-id:591462403 --> @AphroMad commented on GitHub (Feb 26, 2020): Theeeen, now it work but there is an other problem xD i don't know if we can do it but is it possible to connect multiple accounts with the API ? and if yes, how can i switch the action ? Like, i want account A play this music et account B playing this one Is this possible ?
Author
Owner

@stephanebruckert commented on GitHub (Feb 26, 2020):

@AphroMad what did you change for it to work?

Answered your other question here https://github.com/plamere/spotipy/issues/446#issuecomment-591664527

<!-- gh-comment-id:591664701 --> @stephanebruckert commented on GitHub (Feb 26, 2020): @AphroMad what did you change for it to work? Answered your other question here https://github.com/plamere/spotipy/issues/446#issuecomment-591664527
Author
Owner

@AphroMad commented on GitHub (Feb 27, 2020):

i think it was a problem of time
i tried to reconnect the account one time per 30 seconds

but if i try to reconnect only like 1 time per 3 minutes, it works

<!-- gh-comment-id:591886142 --> @AphroMad commented on GitHub (Feb 27, 2020): i think it was a problem of time i tried to reconnect the account one time per 30 seconds but if i try to reconnect only like 1 time per 3 minutes, it works
Author
Owner

@stephanebruckert commented on GitHub (Feb 27, 2020):

Thanks for the feedback, but if it is still happening you should definitely report it on https://github.com/spotify/web-api/

<!-- gh-comment-id:591886733 --> @stephanebruckert commented on GitHub (Feb 27, 2020): Thanks for the feedback, but if it is still happening you should definitely report it on https://github.com/spotify/web-api/
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#260
No description provided.