[GH-ISSUE #593] Command failed PREMIUM_REQUIRED #357

Closed
opened 2026-02-27 23:22:10 +03:00 by kerem · 4 comments
Owner

Originally created by @GarsRiche on GitHub (Oct 22, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/593

When I run my script to add music to the queue it returns, Player command failed: Premium required, reason: PREMIUM_REQUIRED.
However, I do have a premium spotify account.
I do not understand.

Originally created by @GarsRiche on GitHub (Oct 22, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/593 When I run my script to add music to the queue it returns, Player command failed: Premium required, reason: PREMIUM_REQUIRED. However, I do have a premium spotify account. I do not understand.
kerem 2026-02-27 23:22:10 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@stephanebruckert commented on GitHub (Oct 22, 2020):

You are likely not using the account you think you are using.

To connect with the right account, initialise your auth_manager by passing show_dialog=True

Please don't forget to provide your code if further help is needed

<!-- gh-comment-id:714311616 --> @stephanebruckert commented on GitHub (Oct 22, 2020): You are likely not using the account you think you are using. To connect with the right account, initialise your `auth_manager` by passing `show_dialog=True` Please don't forget to provide your code if further help is needed
Author
Owner

@GarsRiche commented on GitHub (Oct 22, 2020):

import requests
import spotipy
import json
from spotipy.oauth2 import SpotifyClientCredentials
from spotipy import oauth2
import sys
from spotipy.oauth2 import SpotifyOAuth

PORT_NUMBER = 8080
SPOTIPY_CLIENT_ID = '...................'
SPOTIPY_CLIENT_SECRET = '..................'
SPOTIPY_REDIRECT_URI = 'http://localhost:8080'
SCOPE = 'user-library-read'
CACHE = '.spotipyoauthcache'

spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())

sp_oauth = oauth2.SpotifyOAuth( SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET,SPOTIPY_REDIRECT_URI,scope=SCOPE,cache_path=CACHE )

token_info = sp_oauth.get_cached_token()
if not token_info:
auth_url = sp_oauth.get_authorize_url()
print(auth_url)
response = input('Paste the above link into your browser, then paste the redirect url here: ')

code = sp_oauth.parse_response_code(response)
token_info = sp_oauth.get_access_token(code)

token = token_info['access_token']

else:
if sp_oauth.is_token_expired(token_info):
token_info = sp_oauth.refresh_access_token(token_info['refresh_token'])
token = token_info['access_token']
sp = spotipy.Spotify(auth=token)

#spotify.playlist_add_items('7CEMedHpx9YliLRliGWpls', 'spotify:track:4ax2yCfEFGewYgz6pF5QQp', position=None)

#spotify.playlist_add_items('7CEMedHpx9YliLRliGWpls', 'spotify:track:4ax2yCfEFGewYgz6pF5QQp', position=None)
#spotify.next_track(device_id=None)
spotify.add_to_queue('spotify:track:4ax2yCfEFGewYgz6pF5QQp',device_id=None)

sp = spotipy.Spotify(auth=token)

here is my code
I tried with another account. always the same error.

<!-- gh-comment-id:714422520 --> @GarsRiche commented on GitHub (Oct 22, 2020): import requests import spotipy import json from spotipy.oauth2 import SpotifyClientCredentials from spotipy import oauth2 import sys from spotipy.oauth2 import SpotifyOAuth PORT_NUMBER = 8080 SPOTIPY_CLIENT_ID = '...................' SPOTIPY_CLIENT_SECRET = '..................' SPOTIPY_REDIRECT_URI = 'http://localhost:8080' SCOPE = 'user-library-read' CACHE = '.spotipyoauthcache' spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials()) sp_oauth = oauth2.SpotifyOAuth( SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET,SPOTIPY_REDIRECT_URI,scope=SCOPE,cache_path=CACHE ) token_info = sp_oauth.get_cached_token() if not token_info: auth_url = sp_oauth.get_authorize_url() print(auth_url) response = input('Paste the above link into your browser, then paste the redirect url here: ') code = sp_oauth.parse_response_code(response) token_info = sp_oauth.get_access_token(code) token = token_info['access_token'] else: if sp_oauth.is_token_expired(token_info): token_info = sp_oauth.refresh_access_token(token_info['refresh_token']) token = token_info['access_token'] sp = spotipy.Spotify(auth=token) #spotify.playlist_add_items('7CEMedHpx9YliLRliGWpls', 'spotify:track:4ax2yCfEFGewYgz6pF5QQp', position=None) #spotify.playlist_add_items('7CEMedHpx9YliLRliGWpls', 'spotify:track:4ax2yCfEFGewYgz6pF5QQp', position=None) #spotify.next_track(device_id=None) spotify.add_to_queue('spotify:track:4ax2yCfEFGewYgz6pF5QQp',device_id=None) sp = spotipy.Spotify(auth=token) here is my code I tried with another account. always the same error.
Author
Owner

@stephanebruckert commented on GitHub (Oct 22, 2020):

You are using SpotifyClientCredentials() which means the generated access token doesn't belong to any user, therefore it can't be premium.

You need to use SpotifyOAuth() instead so that your user can authenticate. Your code looks a bit messy, I suggest you start from scratch from this very simple example https://github.com/plamere/spotipy#with-user-authentication, and then just call add_to_queue at the end

<!-- gh-comment-id:714634675 --> @stephanebruckert commented on GitHub (Oct 22, 2020): You are using `SpotifyClientCredentials()` which means the generated access token doesn't belong to any user, therefore it can't be premium. You need to use `SpotifyOAuth()` instead so that your user can authenticate. Your code looks a bit messy, I suggest you start from scratch from this very simple example https://github.com/plamere/spotipy#with-user-authentication, and then just call `add_to_queue` at the end
Author
Owner

@stephanebruckert commented on GitHub (Oct 24, 2020):

Closing this for now, but feel free to reopen if you still encounter the same problem while using SpotifyOAuth()

<!-- gh-comment-id:715918371 --> @stephanebruckert commented on GitHub (Oct 24, 2020): Closing this for now, but feel free to reopen if you still encounter the same problem while using `SpotifyOAuth()`
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#357
No description provided.