Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Basic authentication #71

wants to merge 1 commit into from

2 participants


0.4.0 breaks authentication.

Added a sweet little fix that makes it working again.


Authentication works properly in 0.4.0; just put the credentials on a URL record (or, alternatively, inline in a URL string). From the README:

(def db (assoc (cemerick.url/url "")
                 :username "username"
                 :password "password"
                 :path "databasename"))

Does this help?

@cemerick cemerick closed this


It does work on Windows, Lein 1.7.1. It doesn't work on Mac, Lein 2.0.0. It doesn't work for both URL string and URL record.

I just noticed Clojure on Win is at 1.2.1, while on Mac it's 1.3.0, but my project.clj asks for 1.4.0. Windows box is not my primary development machine, I was just around it and it was convenient to run a quick test...

I guess I need to investigate it some more.


The handling of authentication fields by url should be entirely unaffected by platform, lein version, or Clojure version. Of course, YMMV, but I'd be really surprised if those factors were in play here.


Exactly. I'm sitting here puzzled.

What I'm planning to do when I get a moment is to check versions of all dependencies that do take part in this (cemerick.url, clj-http etc). I might also just clean Maven caches and re-download all packages on both machines.

Leiningen changed the way the classpath is build between 1.x and 2.0. That might have some impact (and would hint a bug in lein, if it turns out to be the case).


Also, clutch 0.3.1 worked on the Mac.


Found it. It was Leiningen after all.

In 2.0.0, lein repl loads clj-http 0.3.5 on start. So when clutch asks for it, hoping to get 0.4.1, the older version is referenced.

Running the very same code with lein run shows that clutch works very well indeed.


Are you working on a Leiningen plugin? That's the only circumstance where its dependencies would ever potentially come into play. (Clutch is tested and built with lein 2, which doesn't interfere there.)

Feel free to post your project.clj, if you think that will be clarifying.


No, I don't work on a Leiningen plugin. The problem with conflicting clj-http jars only occurs in lein repl. lein run works fine. I'm using 2.0.0-preview10 version of lein (that's what Homebrew let's me easily install). I haven't tried with HEAD version of lein. I plan to, but can't at the moment (day job, sigh).

The project.clj contains nothing interesting. I've just started the project.

(defproject blahblah-gui "0.1.0-SNAPSHOT"
  :description "Blah Blah (GUI)"
  :url ""
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [noir "1.2.2"]
                 [com.ashafa/clutch "0.4.0-SNAPSHOT"]]
  :main blahblah.gui.server)

Oh....this is because lein repl adds a dependency on [org.thnetos/cd-client "0.3.4"], which ropes in the older version of clj-http. Damn.

The workaround at the moment would be to put [clj-http "0.5.5"] in your project.clj, which will override that. Meanwhile, here's the issue you should track for now:



"cemerick opened this issue 8 months ago"

That gives hope :)

Thanks for the workaround.


Sorry, I originally linked to a related, but far more difficult problem. technomancy/leiningen#815 is your issue, and far more tractable AFAICT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 10, 2012
  1. @tomob

    Fixed basic authentication

    tomob authored
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 0 deletions.
  1. +2 −0  src/com/ashafa/clutch/http_client.clj
2  src/com/ashafa/clutch/http_client.clj
@@ -48,6 +48,8 @@ complete HTTP response of the last couchdb request."
(let [resp (http/request (merge configuration
{:url (str request)}
(when data {:body data})
+ (when (and (:username request) (:password request))
+ {:basic-auth (str (:username request) ":" (:password request))})
(when (instance? InputStream data)
{:length (:data-length request)})))]
(set!-*response* resp))
Something went wrong with that request. Please try again.