gpt4 book ai didi

javascript - 尝试使用其 API 在 Spotify 中创建播放列表时出现 "Request failed with status code 401"错误

转载 作者:行者123 更新时间:2023-12-04 10:48:53 25 4
gpt4 key购买 nike

这是我正在使用的代码:

    await axios.post(arg.url,
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${SPYauthToken}`
},
params: {name: "playlist"},

}
)

我之前已经提供了对所有必要范围的访问权限并获得了相应的身份验证 token ,但是当我尝试使用我提供的代码创建播放列表时,我收到一条错误消息“请求失败,状态代码 401”。

当我尝试在 Spotify 自己的 API 站点中创建播放列表时,它也不起作用: https://developer.spotify.com/console/post-playlists/使用他们自己的示例单击“尝试”后,没有任何 react ,也没有为我创建播放列表。

我做错了什么,还是Spotify必须解决的问题?

谢谢!

最佳答案

没试过,但你可以做以下

    // request data object
const data = {
name: "playlist"
};

// set the headers
const config = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${SPYauthToken}`
}
};

await axios.post(arg.url, data, config);
// maybe you need to stringify data so
await axios.post(arg.url, JSON.stringify(data), config);

关于javascript - 尝试使用其 API 在 Spotify 中创建播放列表时出现 "Request failed with status code 401"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59575400/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com