【问题标题】:Spotify Web API Error 400: "Only valid bearer authentication supported"Spotify Web API 错误 400:“仅支持有效的不记名身份验证”
【发布时间】:2020-07-01 04:48:57
【问题描述】:

我正在尝试使用 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);
    }
  );
});

我不明白问题出在哪里,我已经阅读了我能找到的所有内容,但一无所获。我应该使用不同的访问密钥吗?

【问题讨论】:

    标签: node.js spotify webapi


    【解决方案1】:

    查看 Spotify 的 Authorisation Guide,您可以使用 Client Id 和 Client Secret 获取 Access Token 和这是您在向您尝试使用的Search for an Item 端点发出请求时作为 Authorization 标头的一部分发送

    【讨论】:

      猜你喜欢
      • 2020-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-06
      • 2022-11-23
      • 2014-03-25
      • 2020-07-05
      • 2020-06-18
      相关资源
      最近更新 更多