INVALID_CLIENT 尝试使用 Spotipy 授权 api 调用时

INVALID_CLIENT when trying to use Spotipy to authorize an api call

我正在尝试调用 Spotify API 并设置了 app/got 我的客户端 ID 和密码。这是我的代码示例(具体内容已屏蔽):

import spotipy
import spotipy.util as util
from spotipy.oauth2 import SpotifyClientCredentials

cid ="xx" 
secret = "xx"
username = "xx"

client_credentials_manager = SpotifyClientCredentials(client_id=cid, client_secret=secret) 
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)

scope = 'user-library-read playlist-read-private'
token = util.prompt_for_user_token(username,scope,client_id='http://localhost:8888/callback/',client_secret='http://localhost:8888/callback/',redirect_uri='http://localhost:8888/callback/')

if token:
    sp = spotipy.Spotify(auth=token)
else:
    print("Can't get token for", username)
cache_token = token.get_access_token()

sp = spotipy.Spotify(cache_token)
currentfaves = sp.current_user_top_tracks(limit=20, offset=0, time_range='medium_term')

print(currentfaves)

我已确保我的 URL 与我在 Spotify 应用程序开发页面中注册的内容完全相同,并且我已将客户端 ID、重定向 URI 和客户端密钥添加到我的环境变量中。

到目前为止,一个单独的选项卡已打开 (https://accounts.spotify.com/authorize?client_id=http%3A%2F%2Flocalhost%3A8888%2Fcallback%2F&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8888%2Fcallback%2F&scope=playlist-read-private+user-library-read),但我在该页面上只得到 'INVALID_CLIENT: Invalid client'。我可以 do/change 做些什么?

token = util.prompt_for_user_token(username,scope,client_id='http://localhost:8888/callback/',client_secret='http://localhost:8888/callback/',redirect_uri='http://localhost:8888/callback/')

这里是否有错别字,因为您还复制了重定向 uri 作为客户端 ID 和密码?