How to do unauthenticated access using python-cloudant

277 Views Asked by At

I am getting used to using python-cloudant for authenticated access to Cloudant databases but want to do unauthenticated access from a Python script. I set up unauthenticated read access to one of the databases for my account and can read documents fine using curl without authentication but I don't know how to do this using python-cloudant. I've tried using (None, None), ("nobody", "none"), even some credentials that I use for databases for a completely different account but get denied access.

2

There are 2 best solutions below

0
On BEST ANSWER

I think I got the right combination. I don't know what I was doing earlier but when I authenticate with a valid API key & access token, I got access even though the API key doesn't have explicit access to the database.

0
On

You could use the CouchDB client and set admin party mode. That way you don't need to specify credentials in the client constructor.

    from cloudant.client import CouchDB
    client = CouchDB(None, None, url='https://user.cloudant.com', admin_party=True, connect=True)
    db = client['mydb']  # my world readable database

    print db.doc_count()

See the docs for more info.