mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 08:35:49 +03:00
[GH-ISSUE #593] Command failed PREMIUM_REQUIRED #357
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#357
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 @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.
@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_managerby passingshow_dialog=TruePlease don't forget to provide your code if further help is needed
@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: ')
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.
@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 calladd_to_queueat the end@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()