Skip to content

Commit

Permalink
code cleanup for workflow.clj
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarth committed May 16, 2014
1 parent 1ede5cf commit a1439aa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/friend_oauth2/workflow.clj
Expand Up @@ -20,12 +20,10 @@
"POSTs request to OAauth2 provider for authorization token."
[{:keys [uri-config access-token-parsefn]} code]
(let [access-token-uri (:access-token-uri uri-config)
query-map (merge {:grant_type "authorization_code"}
(util/replace-authz-code access-token-uri code))
token-url (assoc access-token-uri :query query-map)
token-response (client/post (:url token-url) {:form-params (:query token-url)})
query-map (assoc (util/replace-authz-code access-token-uri code)
:grant_type "authorization_code")
token-parse-fn (or access-token-parsefn util/extract-access-token)]
(token-parse-fn token-response)))
(token-parse-fn (client/post (:url access-token-uri) {:form-params query-map}))))

(defn- redirect-to-provider!
"Redirects user to OAuth2 provider. Code should be in response."
Expand All @@ -41,7 +39,7 @@
"Workflow for OAuth2"
[config]
(fn [request]
(if (is-oauth2-callback? config request)
(when (is-oauth2-callback? config request)
;; Extracts code from request if we are getting here via OAuth2 callback.
;; http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1.2
(let [{:keys [state code]} (:params request)
Expand Down

0 comments on commit a1439aa

Please sign in to comment.