按照我的最后一个问题,但为了保持代码同质,我想使用 httpkit 来发出请求,而不是像之前那样使用 clj-http。
我可以通过以下方式尝试从 Spotify API 接收我的个人资料:
(defn get-me [token]
@(client/request
{:url "https://api.spotify.com/v1/me"
:method :get
:headers {"Authorization" token
"Accept" "application/json"
"Content-Type" "application/json"}}))
(defn get-me-handler [req]
(let [res (:token @TOKEN)]
(if (= res "")
{:status 404
:headers {"Content-Type" "text/html"}
:body "Not logged in"}
{:status 200
:headers {"Content-Type" "text/html"}
:body (get-me (get (json/read-str res) "access_token"))})))
一个很长的“localhost:{port}/me”路线。当我访问这条路线时,我返回:
{"status": 400, "message": "Only valid bearer authentication supported" }}"
作为错误消息。有谁知道如何在 httpkit 中解决这个问题,因为这不是我在 clj-http 中遇到的问题?
有效承载认证中的令牌应以“Bearer”开头