【问题标题】:How do I resolve this Client ID Error from Spotipy?如何从 Spotipy 解决此客户端 ID 错误?
【发布时间】:2020-08-13 15:55:40
【问题描述】:

我正在尝试使用 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'])

【问题讨论】:

    标签: python python-3.x spotify


    【解决方案1】:

    不使用环境变量进行身份验证的正确方法是使用 SpotifyOAuth 并提供以下凭据:

    spotify = spotipy.Spotify(auth_manager = SpotifyOAuth(client_id = '',
                                                          client_secret = '',
                                                          redirect_uri = '',
                                                          user = ''))
    

    【讨论】:

    • 我在哪里可以获得我的客户 ID?谢谢!
    • @TheMartian32 你应该在developer.spotify.com/dashboard创建一个应用程序
    • 好的,现在客户端 ID 可以正常工作,但我收到了这个新错误 Spotify0Auth 未定义。
    • 对不起!忘了说需要在代码顶部加from spotipy.oauth2 import SpotifyOAuth
    • 再次感谢!但我向上帝发誓,我今天被诅咒了,因为这又引发了另一个错误,说我没有“client_secret”。
    猜你喜欢
    • 2019-10-03
    • 2022-11-14
    • 1970-01-01
    • 2020-02-18
    • 2018-10-29
    • 1970-01-01
    • 1970-01-01
    • 2022-11-09
    • 1970-01-01
    相关资源
    最近更新 更多