dennismonsewicz
dennismonsewicz

Reputation: 25552

Using the Cloudant-Python Library to connect using API Keys

I am trying to use the cloudant python library (http://cloudant-labs.github.io/cloudant-python/) in a Flask application but I can't see where you would use API keys to connect to your cloudant account

I tried this:

import cloudant

account = cloudant.Account('account_name')
login = account.login('public_key', 'private_key')

But it doesn't do anything

Upvotes: 1

Views: 482

Answers (2)

Simon Fearby
Simon Fearby

Reputation: 187

not cloud ant but raw code

import requests
import json

#basic authentication
auth = ('account', 'private_key')

post_url = "https://account_name.cloudant.com/database".format(auth[0])
r = requests.put(post_url, auth=auth)

print json.dumps(r.json(), indent=1)

Upvotes: 0

Chad_C
Chad_C

Reputation: 188

It looks like you posted this to github. I wanted others to be able to find the answer.

https://github.com/cloudant-labs/cloudant-python/issues/43:

import cloudant

account = cloudant.Account(USERNAME, auth=(API_KEY, API_SECRET))

Upvotes: 2

Related Questions