r0man / oauth-clj

Clojure OAuth library
97 stars 27 forks source link

oauth.v1 post throws exception with more than one param #1

Closed gregspurrier closed 12 years ago

gregspurrier commented 12 years ago

When the post body of an oauth.v1 client contains more than one parameter, the operation will throw a java.lang.IllegalArgumentException:

(use 'oauth.v1)

(def client (oauth-client "123" "456" "789" "abz"))

;; One param: no exception
(client {:method :post
         :url "http://localhost:3000/some/url"
         :form-params {:foo "bar"}})

;; Two params: boom!
(client {:method :post
         :url "http://localhost:3000/some/url"
         :form-params {:foo "bar" :baz "buzz"}})

In the latter example, I get the following stack trace:

No value supplied for key: buzz
  [Thrown class java.lang.IllegalArgumentException]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0: clojure.lang.PersistentHashMap.createWithCheck(PersistentHashMap.java:89)
  1: clojure.core$hash_map.doInvoke(core.clj:355)
  2: clojure.lang.RestFn.applyTo(RestFn.java:137)
  3: clojure.core$apply.invoke(core.clj:600)
  4: oauth.util$parse_body_params.invoke(util.clj:109)
  5: oauth.v1$oauth_signature_parameters.invoke(v1.clj:29)
  6: oauth.v1$oauth_parameter_string.invoke(v1.clj:36)
  7: oauth.v1$oauth_signature_base.invoke(v1.clj:43)
  8: oauth.v1$oauth_request_signature.doInvoke(v1.clj:54)
  9: clojure.lang.RestFn.invoke(RestFn.java:439)
 --more--

I see the same behavior if I use a :body parameter and manually encode the params.

gregspurrier commented 12 years ago

Fixed as of 0.0.3.