[GH-ISSUE #308] I can't get no device id on Spotify API (even if I have a token) #177

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

Originally created by @OueOue on GitHub (Jul 24, 2018).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/308

Hi, i'm just trying to start a song on Spotify, I found the way to have a token, but now that I ask for my list of devices, it tells me that the Permission is missing
So here is my code :


import sys
import spotipy
import spotipy.util as util
username = 'OueOue'
token = util.prompt_for_user_token(username, scope = 'user-modify-playback-state', client_id='MyClientID', client_secret='MySecretID', redirect_uri = 'https://open.spotify.com/browse/featured')
if token:
print("Token OK")
sp = spotipy.Spotify(auth=token)
print("Authentication OK")
sp.start_playback(device_id = sp.devices(), context_uri = 'spotify:track:7MywASx2OFZngfoORjo1yy', uris = None, offset = None)
print("SMAH")
else:
print("Can't get token for %s" % username)


errors
Thank you for your time :)

Originally created by @OueOue on GitHub (Jul 24, 2018). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/308 Hi, i'm just trying to start a song on Spotify, I found the way to have a token, but now that I ask for my list of devices, it tells me that the Permission is missing So here is my code : _______________________________________________________________________________________________________________ import sys import spotipy import spotipy.util as util username = 'OueOue' token = util.prompt_for_user_token(username, scope = 'user-modify-playback-state', client_id='MyClientID', client_secret='MySecretID', redirect_uri = 'https://open.spotify.com/browse/featured') if token: print("Token OK") sp = spotipy.Spotify(auth=token) print("Authentication OK") sp.start_playback(device_id = sp.devices(), context_uri = 'spotify:track:7MywASx2OFZngfoORjo1yy', uris = None, offset = None) print("SMAH") else: print("Can't get token for %s" % username) _______________________________________________________________________________________________________________ ![errors](https://user-images.githubusercontent.com/41620395/43130362-d59a4dc4-8f36-11e8-8460-213810c1b5de.PNG) Thank you for your time :)
kerem closed this issue 2026-02-27 23:21:13 +03:00
Author
Owner

@rperkett-r7 commented on GitHub (Jul 24, 2018):

I doubt it, but tell me if you find the answer to this. Thanks.

<!-- gh-comment-id:407542712 --> @rperkett-r7 commented on GitHub (Jul 24, 2018): I doubt it, but tell me if you find the answer to this. Thanks.
Author
Owner

@OueOue commented on GitHub (Jul 25, 2018):

I found an unsatisfying solution, get the device ID from :
https://developer.spotify.com/console/put-play/
and click on "fill sample data"
but the problem is that I will only be able to start or resume a playback on my computer, and not on other devices, that's why i'm waiting for another solution

<!-- gh-comment-id:407693091 --> @OueOue commented on GitHub (Jul 25, 2018): I found an unsatisfying solution, get the device ID from : https://developer.spotify.com/console/put-play/ and click on "fill sample data" but the problem is that I will only be able to start or resume a playback on my computer, and not on other devices, that's why i'm waiting for another solution
Author
Owner

@danitico commented on GitHub (Jul 28, 2018):

Same problem

<!-- gh-comment-id:408624213 --> @danitico commented on GitHub (Jul 28, 2018): Same problem
Author
Owner

@OueOue commented on GitHub (Jul 30, 2018):

I GOT THE SOLUTION !
First connect on spotify on all the devices you would like to use (for example your laptop, mobile phone, and your desktop pc), go here : https://developer.spotify.com/console/get-users-available-devices/

Then ask for a token, do Win+cmd , copy the curl request and paste it in cmd :
You'll normally get the list of all the devices currently connected to your spotify account.

Now do an array of string (bi-dimensional array of characters), let's call it Dvcs[3][40].
[3] because I have only 3 IDs, [40] because a device ID is a string of 40 characters.

Fill it with the IDs of your devices, then just do a function in your program that allows you to choose on which device to play the track (like choosing i = 1 or 2 or 3 and then select Dvcs[i][]).
I hope it has been helpful to you guys ! 😄

<!-- gh-comment-id:408855956 --> @OueOue commented on GitHub (Jul 30, 2018): I GOT THE SOLUTION ! First connect on spotify on all the devices you would like to use (for example your laptop, mobile phone, and your desktop pc), go here : https://developer.spotify.com/console/get-users-available-devices/ Then ask for a token, do Win+cmd , copy the curl request and paste it in cmd : You'll normally get the list of all the devices currently connected to your spotify account. Now do an array of string (bi-dimensional array of characters), let's call it Dvcs[3][40]. [3] because I have only 3 IDs, [40] because a device ID is a string of 40 characters. Fill it with the IDs of your devices, then just do a function in your program that allows you to choose on which device to play the track (like choosing i = 1 or 2 or 3 and then select Dvcs[i][]). I hope it has been helpful to you guys ! 😄
Author
Owner

@rperkett-r7 commented on GitHub (Jul 30, 2018):

I wish there was some way to have the token not have to be manually updated every time :<

<!-- gh-comment-id:408875660 --> @rperkett-r7 commented on GitHub (Jul 30, 2018): I wish there was some way to have the token not have to be manually updated every time :<
Author
Owner

@Birath commented on GitHub (Aug 9, 2018):

You need to add user-read-playback-state to your scope to read the device id (and other device information). You can find more information about scopes here: https://developer.spotify.com/documentation/general/guides/scopes/

<!-- gh-comment-id:411891650 --> @Birath commented on GitHub (Aug 9, 2018): You need to add `user-read-playback-state` to your scope to read the device id (and other device information). You can find more information about scopes here: https://developer.spotify.com/documentation/general/guides/scopes/
Author
Owner

@stephanebruckert commented on GitHub (Jan 12, 2020):

Looks like it was a scope problem, closing

<!-- gh-comment-id:573427329 --> @stephanebruckert commented on GitHub (Jan 12, 2020): Looks like it was a scope problem, closing
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#177
No description provided.