A more complete example for googlers:
from couchdb import Server
s = Server("
https://user:pass...@example.com:6984")
# Request the cookie: url encoded above and below, of course
# You have to put the credentials twice to get started with the first cookie
# Both in the Server() constructor as well as the _session POST body
code, message, obj =
s.resource.post('_session',headers={'Content-Type' : 'application/x-www-form-urlencoded'}, body="name=user&password=password")
assert(code == 200)
# Now you have received a cookie, extract it
cookie = message["Set-Cookie"].split(";", 1)[0].strip()
# exit python and restart
# Request a server object, but without the username and password this time
s = Server("
https://example.com:6984")
s.resource.headers["Cookie"] = cookie
# Yay, no password.
db = s["database"]
Optionally set the "persistent" cookie option on the server side to make the cookie last longer.
- Michael