使用 python 使用 Spotify API 时出现用户名无效错误

问题描述 投票:0回答:1

我使用下面的 python 程序使用 Spotify API 生成令牌

import requests

CLIENT_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
CLIENT_SECRET = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyy'

AUTH_URL = 'https://accounts.spotify.com/api/token'

# POST
auth_response = requests.post(AUTH_URL, {
    'grant_type': 'client_credentials',
    'client_id': CLIENT_ID,
    'client_secret': CLIENT_SECRET,
})

# convert the response to JSON
auth_response_data = auth_response.json()

# save the access token
access_token = auth_response_data['access_token']

print("token is ")
print(access_token)

这会打印令牌

现在我正在尝试使用此命令使用此令牌卷曲并获取当前播放曲目

curl -X "GET" "https://api.spotify.com/v1/me/player/currently-playing?market=ES" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxGenrated Tokenxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

但是我收到无效的用户名错误,如何解决这个问题

{
  "error" : {
    "status" : 404,
    "message" : "Invalid username"
  }
}
python spotify
1个回答
0
投票

你解决了吗?我遇到同样的错误

© www.soinside.com 2019 - 2024. All rights reserved.