clj-oauth
clj-oauth copied to clipboard
How to get twitter verify_credentials ?
I used clj-oauth to successfully login to twitter and fetch access-token. However when I try to invoke twitter api for "https://api.twitter.com/1/account/verify_credentials.json", I am getting a 401.
I suspect the (http/get ... ) is not setting the credentials correctly.
(defn handle-twitter-token-credentials [oauth_token oauth_verifier]
{:status 200
:headers {"Content-Type" "text/html"}
:body (let [
access-token-response (oauth/access-token consumer request-token oauth_verifier)
_ (println " access-token-response: " access-token-response)
req-credentials (oauth/credentials consumer
(:oauth_token access-token-response)
(:oauth_token_secret access-token-response)
:GET
"https://api.twitter.com/1/account/verify_credentials.json"
)
; this is ok so far
_ (println "credentials: " req-credentials)
; this breaks at http/get with 401 . The req-credentials looks ok
; I think http/get is not setting the authorization headers correctly
;
info (http/get "https://api.twitter.com/1/account/verify_credentials.json"
{:query-params req-credentials})
_ (println "got info ")
_ (println "class " (class info))
_ (println (str into))
]
(with-out-str "Ok")
)} )
Hello, thanks for the report. First, you should be using version 1.1 of the Twitter REST API. Please check if that works for you.
Are other authenticated Twitter REST API calls failing with a 401 as well?
I should've tested a little more before commenting. The URL https://api.twitter.com/1/account/verify_credentials.json is for major version 1 and using 1.0 explicitly results in a different error.
Will take a closer look.