1

我正在按照这些步骤https://secure.flickr.com/services/api/auth.oauth.html在我的 clojure prog 中实现 oauth。

使用以下代码,第 3 步一切正常。(printlns 仅用于检查返回值)

(def consumer-key "0000")
(def consumer-secret "0000")

(def consumer (oauth.client/make-consumer consumer-key
            consumer-secret
            "http://www.flickr.com/services/oauth/request_token"
            "http://www.flickr.com/services/oauth/access_token"
            "http://www.flickr.com/services/oauth/authorize"
            :hmac-sha1))

(def request-token (oauth/request-token consumer "http://localhost:8080/authorize"))

(defn flickrauth []
         (def auth-url (oauth/user-approval-uri consumer
         (:oauth_token request-token)))
         (println (str auth-url "&perms=write")))

在我的浏览器中输入 auth-url 后,可以授权具有写权限的访问。

(defn get-access-token [oauth-token verifier]
         (println "CONSUMER: " consumer "REQ TOKEN: " oauth-token "verifier: " verifier)

在下面的代码中,我只得到“oauth_problem=token_rejected,状态 401”。所以我想将请求令牌交换为访问令牌存在问题......

(def access-token-response (oauth/access-token consumer
                           request-token
                           verifier))

(println "ACCESS TOKEN RESPONSE: " access-token-response)

简短的总结......我得到了一个请求令牌和验证器,但在访问令牌响应中使用了另一个 oauth_token ......我不知道为什么。

感谢您的帮助和提示!

4

0 回答 0