小编Eri*_*rik的帖子

使用 Spotify API 时“解析 JSON 时出错”

我正在学习 Python,并尝试使用 Spotify Web api 创建播放列表,但收到 http 400 错误:解析 json 时出错。我想这与令牌中不正确的变量类型有关,但我很难调试它,因为我无法找到一种方法来查看原始格式的发布请求。

通过 API 发布需要授权,这是我为此创建的脚本:

import requests
import base64
requests.packages.urllib3.disable_warnings()

client_id = 'ID'
client_secret = 'SECRET'
redirect_uri = 'http://spotify.com/'
scope = 'playlist-modify-private playlist-read-private'

def request_token():

    #  1. Your application requests authorization
    auth_url = 'https://accounts.spotify.com/authorize'
    payload = {'client_id': client_id, 'response_type':'code','redirect_uri':redirect_uri}
    auth = requests.get(auth_url,params = payload)
    print '\nPlease go to this url to authorize ', auth.url

    #  2. The user is asked to authorize access within the scopes
    #  3. The user is …
Run Code Online (Sandbox Code Playgroud)

python api json token spotify

3
推荐指数
1
解决办法
2630
查看次数

标签 统计

api ×1

json ×1

python ×1

spotify ×1

token ×1