From 00a27e28bb405897b0170b8f39ef28111bf21368 Mon Sep 17 00:00:00 2001 From: Adam Wynne Date: Sat, 24 Sep 2011 18:02:56 +0100 Subject: [PATCH 1/6] made ready for clojure 1.3 --- project.clj | 9 +++++---- test/oauth/signature_test.clj | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/project.clj b/project.clj index fb5e338..77d61b6 100644 --- a/project.clj +++ b/project.clj @@ -1,9 +1,10 @@ -(defproject clj-oauth "1.2.10-SNAPSHOT" +(defproject org.clojars.adamwynne/clj-oauth "1.2.11" :description "OAuth support for Clojure" - :dependencies [[org.clojure/clojure "1.2.0"] - [com.twinql.clojure/clj-apache-http "2.3.1"] + :dependencies [[org.clojure/clojure "1.3.0"] + [org.clojars.adamwynne/clj-apache-http "2.3.2"] [org.apache.httpcomponents/httpclient "4.1"] [org.apache.httpcomponents/httpcore "4.1"] [org.apache.httpcomponents/httpmime "4.1"]] - :dev-dependencies [[swank-clojure "1.3.0-SNAPSHOT"]]) + :dev-dependencies [[lein-clojars "0.6.0"] + [swank-clojure "1.3.2"]]) diff --git a/test/oauth/signature_test.clj b/test/oauth/signature_test.clj index 003d4e4..f50cfda 100644 --- a/test/oauth/signature_test.clj +++ b/test/oauth/signature_test.clj @@ -242,11 +242,11 @@ url-form-encode (is (= (sig/url-form-encode {}) "")) (is (= (sig/url-form-encode {"hello" "there"}) "hello=there")) - (is (= (sig/url-form-encode {"hello" "there" "name" "Bill" }) "hello=there&name=Bill")) + (is (= (sig/url-form-encode {"hello" "there" "name" "Bill" }) "name=Bill&hello=there")) (is (= (sig/url-form-encode {:hello "there"}) "hello=there")) - (is (= (sig/url-form-encode {:hello "there" :name "Bill" }) "hello=there&name=Bill")) + (is (= (sig/url-form-encode {:hello "there" :name "Bill" }) "name=Bill&hello=there")) (is (= (sig/url-form-encode {:hello "there"}) "hello=there")) - (is (= (sig/url-form-encode {:hello "there" :name "Bill Smith" }) "hello=there&name=Bill%20Smith"))) + (is (= (sig/url-form-encode {:hello "there" :name "Bill Smith" }) "name=Bill%20Smith&hello=there"))) From 7ba5741cc2f051f6f26d1fbc4752fb169c7fa1f8 Mon Sep 17 00:00:00 2001 From: Adam Wynne Date: Thu, 8 Dec 2011 10:42:17 +0000 Subject: [PATCH 2/6] change the consumer struct into a record (for serialization) --- project.clj | 2 +- src/oauth/client.clj | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/project.clj b/project.clj index 77d61b6..8682c3e 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.clojars.adamwynne/clj-oauth "1.2.11" +(defproject org.clojars.adamwynne/clj-oauth "1.2.12" :description "OAuth support for Clojure" :dependencies [[org.clojure/clojure "1.3.0"] [org.clojars.adamwynne/clj-apache-http "2.3.2"] diff --git a/src/oauth/client.clj b/src/oauth/client.clj index 42edf22..3a3cdd9 100644 --- a/src/oauth/client.clj +++ b/src/oauth/client.clj @@ -10,13 +10,13 @@ (declare success-content authorization-header) -(defstruct #^{:doc "OAuth consumer"} consumer - :key - :secret - :request-uri - :access-uri - :authorize-uri - :signature-method) +(defrecord #^{:doc "OAuth consumer"} consumer + [key + secret + request-uri + access-uri + authorize-uri + signature-method]) (defn check-success-response [m] (let [code (:code m)] @@ -32,13 +32,12 @@ (defn make-consumer "Make a consumer struct map." [key secret request-uri access-uri authorize-uri signature-method] - (struct consumer - key - secret - request-uri - access-uri - authorize-uri - signature-method)) + (consumer. key + secret + request-uri + access-uri + authorize-uri + signature-method)) ;;; Parse form-encoded bodies from OAuth responses. (defmethod http/entity-as :urldecoded From 57b9699e101c7c2a8ded22ec0a7172f7562bbac8 Mon Sep 17 00:00:00 2001 From: Adam Wynne Date: Thu, 19 Apr 2012 12:19:30 +0100 Subject: [PATCH 3/6] added params to the authorize call --- project.clj | 2 +- src/oauth/client.clj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/project.clj b/project.clj index 8682c3e..7fe5bec 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.clojars.adamwynne/clj-oauth "1.2.12" +(defproject org.clojars.adamwynne/clj-oauth "1.2.13" :description "OAuth support for Clojure" :dependencies [[org.clojure/clojure "1.3.0"] [org.clojars.adamwynne/clj-apache-http "2.3.2"] diff --git a/src/oauth/client.clj b/src/oauth/client.clj index 3a3cdd9..9859ac8 100644 --- a/src/oauth/client.clj +++ b/src/oauth/client.clj @@ -85,9 +85,9 @@ (defn user-approval-uri "Builds the URI to the Service Provider where the User will be prompted to approve the Consumer's access to their account." - [consumer token] + [consumer token & {:as rest}] (.toString (http/resolve-uri (:authorize-uri consumer) - {:oauth_token token}))) + (merge rest {:oauth_token token})))) (defn access-token "Exchange a request token for an access token. From dda318f7323d2650607666d615395c39fd64d892 Mon Sep 17 00:00:00 2001 From: Adam Wynne Date: Tue, 11 Sep 2012 15:55:19 +0100 Subject: [PATCH 4/6] allowed multiple arguments to be added to the request-token phase --- .lein-deps-sum | 1 + project.clj | 2 +- src/oauth/client.clj | 42 +++++++++++++++--------------------------- 3 files changed, 17 insertions(+), 28 deletions(-) create mode 100644 .lein-deps-sum diff --git a/.lein-deps-sum b/.lein-deps-sum new file mode 100644 index 0000000..e16fd86 --- /dev/null +++ b/.lein-deps-sum @@ -0,0 +1 @@ +1f866930cceb4d7b0541ae4e03c06ad7204e7249 \ No newline at end of file diff --git a/project.clj b/project.clj index 7fe5bec..6b548fd 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.clojars.adamwynne/clj-oauth "1.2.13" +(defproject org.clojars.adamwynne/clj-oauth "1.2.14" :description "OAuth support for Clojure" :dependencies [[org.clojure/clojure "1.3.0"] [org.clojars.adamwynne/clj-apache-http "2.3.2"] diff --git a/src/oauth/client.clj b/src/oauth/client.clj index 9859ac8..3e96116 100644 --- a/src/oauth/client.clj +++ b/src/oauth/client.clj @@ -54,33 +54,21 @@ (defn request-token "Fetch request token for the consumer." - ([consumer] - (let [unsigned-params (sig/oauth-params consumer) - signature (sig/sign consumer - (sig/base-string "POST" - (:request-uri consumer) - unsigned-params)) - params (assoc unsigned-params - :oauth_signature signature)] - (success-content - (http/post (:request-uri consumer) - :headers {"Authorization" (authorization-header params)} - :parameters (http/map->params {:use-expect-continue false}) - :as :urldecoded)))) - ([consumer callback-uri] - (let [unsigned-params (assoc (sig/oauth-params consumer) - :oauth_callback callback-uri) - signature (sig/sign consumer - (sig/base-string "POST" - (:request-uri consumer) - unsigned-params)) - params (assoc unsigned-params - :oauth_signature signature)] - (success-content - (http/post (:request-uri consumer) - :headers {"Authorization" (authorization-header params)} - :parameters (http/map->params {:use-expect-continue false}) - :as :urldecoded))))) + [consumer & {:as args}] + + (let [unsigned-params (merge (sig/oauth-params consumer) + args) + signature (sig/sign consumer + (sig/base-string "POST" + (:request-uri consumer) + unsigned-params)) + params (assoc unsigned-params + :oauth_signature signature)] + (success-content + (http/post (:request-uri consumer) + :headers {"Authorization" (authorization-header params)} + :parameters (http/map->params {:use-expect-continue false}) + :as :urldecoded)))) (defn user-approval-uri "Builds the URI to the Service Provider where the User will be prompted From 6b8be4bc33d6be2b23ec1166fd51518c655e2b01 Mon Sep 17 00:00:00 2001 From: Adam Wynne Date: Wed, 30 Jan 2013 17:14:16 +0000 Subject: [PATCH 5/6] more flexible arguments --- .lein-deps-sum | 1 - project.clj | 7 +++---- src/oauth/client.clj | 11 ++++++++--- 3 files changed, 11 insertions(+), 8 deletions(-) delete mode 100644 .lein-deps-sum diff --git a/.lein-deps-sum b/.lein-deps-sum deleted file mode 100644 index e16fd86..0000000 --- a/.lein-deps-sum +++ /dev/null @@ -1 +0,0 @@ -1f866930cceb4d7b0541ae4e03c06ad7204e7249 \ No newline at end of file diff --git a/project.clj b/project.clj index 6b548fd..b649b82 100644 --- a/project.clj +++ b/project.clj @@ -1,10 +1,9 @@ -(defproject org.clojars.adamwynne/clj-oauth "1.2.14" +(defproject org.clojars.adamwynne/clj-oauth "1.2.19" :description "OAuth support for Clojure" - :dependencies [[org.clojure/clojure "1.3.0"] + :dependencies [[org.clojure/clojure "1.4.0"] [org.clojars.adamwynne/clj-apache-http "2.3.2"] [org.apache.httpcomponents/httpclient "4.1"] [org.apache.httpcomponents/httpcore "4.1"] [org.apache.httpcomponents/httpmime "4.1"]] - :dev-dependencies [[lein-clojars "0.6.0"] - [swank-clojure "1.3.2"]]) + :min-lein-version "2.0.0") diff --git a/src/oauth/client.clj b/src/oauth/client.clj index 3e96116..d283af5 100644 --- a/src/oauth/client.clj +++ b/src/oauth/client.clj @@ -56,18 +56,23 @@ "Fetch request token for the consumer." [consumer & {:as args}] - (let [unsigned-params (merge (sig/oauth-params consumer) - args) + (let [extra-parameters (:parameters args) + query (:query args) + unsigned-params (merge (sig/oauth-params consumer) + extra-parameters) signature (sig/sign consumer (sig/base-string "POST" (:request-uri consumer) - unsigned-params)) + (merge unsigned-params + query))) params (assoc unsigned-params :oauth_signature signature)] + (success-content (http/post (:request-uri consumer) :headers {"Authorization" (authorization-header params)} :parameters (http/map->params {:use-expect-continue false}) + :query query :as :urldecoded)))) (defn user-approval-uri From f2d360876ccad0852db900b91058afffe2a4157c Mon Sep 17 00:00:00 2001 From: Adam Wynne Date: Wed, 30 Jan 2013 17:22:25 +0000 Subject: [PATCH 6/6] updated to include the new lein deps file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8bd78af..d1a9e67 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ classes *.jar pom.xml +.lein-deps-sum