You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用httpkit调用Spotify API遇400错误:仅支持Bearer认证的解决方法

问题解决:Spotify API返回"Only valid bearer authentication supported"

错误的核心原因是Authorization请求头格式不符合Spotify API要求。Spotify要求Bearer认证的格式为Bearer {access_token},而你的代码中直接将access_token作为Authorization头的值,缺少了Bearer 前缀。

修改get-me函数中的headers配置即可解决:

(defn get-me [token]
  @(client/request
   {:url "https://api.spotify.com/v1/me"
    :method :get
    :headers {"Authorization" (str "Bearer " token)  ; 添加Bearer前缀
              "Accept" "application/json"
              "Content-Type" "application/json"}}))

额外检查项:

  • 确保从res中读取的access_token是正确的纯字符串,没有被多余的引号包裹
  • 确认当前token处于有效期内,未过期

内容的提问来源于stack exchange,提问作者Jack Gee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 03:05:38