Spotify 网络 API 错误 400:"Only valid bearer authentication supported"
Spotify Web API Error 400: "Only valid bearer authentication supported"
我正在尝试使用 Spotify Web API 通过节点搜索歌曲,但它一直向我发送状态 400 错误消息:“仅支持有效的承载身份验证”。这是我的代码:
app.get("/", (req, res) => {
let searchurl = "https://api.spotify.com/v1/search?";
request.post(
{
url: searchurl,
data: {
q: "john",
type: "album",
},
headers: {
"Content-Type": "application/json",
Authorization:
"Basic " +
Buffer.from(client_id + ":" + client_secret).toString("base64"),
},
method: "POST",
},
function (e, r, body) {
console.log(body);
}
);
});
我不明白问题出在哪里,并且通读了我能找到的所有内容,但一无所获。我应该使用不同的访问密钥吗?
查看您尝试使用的 Authorisation Guide for Spotify, you can use the Client Id and Client Secret to get an Access Token and it is that you send as part of an Authorization header when making the request to the Search for an Item 端点
我正在尝试使用 Spotify Web API 通过节点搜索歌曲,但它一直向我发送状态 400 错误消息:“仅支持有效的承载身份验证”。这是我的代码:
app.get("/", (req, res) => {
let searchurl = "https://api.spotify.com/v1/search?";
request.post(
{
url: searchurl,
data: {
q: "john",
type: "album",
},
headers: {
"Content-Type": "application/json",
Authorization:
"Basic " +
Buffer.from(client_id + ":" + client_secret).toString("base64"),
},
method: "POST",
},
function (e, r, body) {
console.log(body);
}
);
});
我不明白问题出在哪里,并且通读了我能找到的所有内容,但一无所获。我应该使用不同的访问密钥吗?
查看您尝试使用的 Authorisation Guide for Spotify, you can use the Client Id and Client Secret to get an Access Token and it is that you send as part of an Authorization header when making the request to the Search for an Item 端点