John
John

Reputation: 329

How to do unauthenticated access using python-cloudant

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.

Upvotes: 1

Views: 271

Answers (2)

Sam Smith
Sam Smith

Reputation: 41

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.

Upvotes: 2

John
John

Reputation: 329

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.

Upvotes: 0

Related Questions