(NB If you don't understand clojure I can traslate the code in Java, just ask please)
I am using scribe with clojure and I am finding some issue to log in with twitter, the code I am using:
(def twitter-service
(-> (doto
(ServiceBuilder.)
(.provider (TwitterApi$Authenticate.))
(.apiKey "apikey")
(.apiSecret "apisecret")
(.callback "https://morgan-siscia.rhcloud.com/tatata/"))
(.build)))
(def tokens (atom {}))
(defn get-token []
(.getRequestToken twitter-service))
(defn get-twitter-url [token]
(swap! tokens assoc (.getToken token) token)
(.getAuthorizationUrl twitter-service token))
(defn get-info-twitter [oauth-token oauth-veri]
(let [token (get @tokens oauth-token)
verifier (Verifier. oauth-veri)
access-token (.getAccessToken twitter-service token verifier)
request (doto (OAuthRequest. (Verb/POST)
"https://api.twitter.com/oauth/access_token")
(.addOAuthParameter "oauth_token" oauth-token)
(.addBodyParameter "oauth_verifier" oauth-veri))]
(do
(.signRequest twitter-service access-token request)
(swap! tokens dissoc oauth-token))
(.getBody (.send request))))
The code is pretty a straight translation of the java code, however it is not working.
When I call (get-info-twitter "the-oauth-code" "the verifier code") twitter return an error:
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<request>/oauth/access_token</request>
<error>The access_token method must be called with a request_token</error>
</hash>
Honestly I have no idea what I am doing wrong, can somebody help me out ?