Establishing a Connection
The objects available within our connector are accessible from the "cdata.cloudant" module. To use the module's objects directly:
- Import the module as follows:
import cdata.cloudant as mod
- To establish a connection string, call the connect() method from the connector object using an appropriate connection string, such as:
mod.connect("User=abc123; Password=abcdef;")
Authenticating to Cloudant
Cloudant supports two types of authentication:- OAuth: Performs authentication based on the OAuth standard. Set AuthScheme to OAuth and supply the values for the Cloudant instance APIKey and URL.
- Basic: Basic username/password authentication. Set AuthScheme to Basic.
IBM Cloud IAM
IBM Cloud IAM is OAuth-based authentication accessed via a web browser.To authenticate to IBM Cloud, set AuthScheme to OAuth and supply the ApiKey and the Url of the target Cloudant instance (for example, https://0c9d3837-8304-4aab-a65a-648169970943-bluemix.cloudant.com).
After setting InitiateOAuth to GETANDREFRESH, you are ready to connect.
When you connect, the connector completes the OAuth process.
- Extracts the access token and authenticates requests.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Retrieving OAuth connection properties
To retrieve the OAuth connection properties:- Create an account in IBM Cloud.
- Obtain the ApiKey:
- Log in to your IBM Cloud account.
- Navigate to Platform API Keys page.
- To create a new API Key, click Create an IBM Cloud API Key. Cloudant displays a pop-up form.
- Specify the API Key name and click Create. Cloudant displays the
ApiKey you just created.
Save this information for future reference.
Registering a new instance of Cloudant
If you do not already have Cloud Object Storage in your IBM Cloud account, you can install an instance of SQL Query in your account:
- Log in to your IBM Cloud account.
- Navigate to the Cloudant page.
- Choose a name for your instance and click Create. You are redirected to that Cloudant instance.
IBM Cloudant Legacy
To connect via IBM Cloudant Legacy, ensure that you have a valid IBM Cloudant service credential.To create an IBM Cloudant service credential:
- Log in to the IBM Cloud dashboard.
- Navigate to the Menu icon > Resource List, and open your IBM Cloudant service instance.
- In the menu, click Service credentials.
- Click New credential. Cloudant displays a Add new credential window.
- Enter a name for the new credential.
- Click Add. Your credentials are added to the Service credentials table.
- Click Actions > View credentials.
- Extract the values for User and Password from the JSON file.
Use the values you just obtained to set the User and Password.
Authenticating to a Local Instance
Cloudant supports authenticating to data in local instances from version 1.1.0 and above.To authenticate to your local instance, set these parameters:
- Url: The Url of your local instance. For example: http://localhost:8006
- User: Your username.
- Password: Your password.