Clojure httpkit Spotify 请求

问题描述 投票:0回答:1

按照我的最后一个问题,但为了保持代码同质,我想使用 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 中遇到的问题?

api clojure spotify http-kit clj-http
1个回答
0
投票

有效承载认证中的令牌应以“Bearer”开头

© www.soinside.com 2019 - 2024. All rights reserved.