问题描述
我正在尝试使用python做一个Spotify项目,但出现此错误。 “没有client_id。传递它或设置spotipy_client_id环境变量。”
这是我的代码:
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
surfaces_url = 'https://open.spotify.com/artist/4ETSs924pXMzjIeD6E9b4u'
spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
results = spotify.artist_albums(surfaces_url,album_type='album')
albums = results['items']
while results['next']:
results = spotify.next(results)
albums.extend(results['items'])
for album in albums:
print(album['name'])
解决方法
尝试替换
spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
使用
spotify = spotipy.Spotify(auth_manager = SpotifyOAuth(client_id = 'your client id here'))
看看是否有帮助