Establishing a Connection
The objects available within our connector are accessible from the "cdata.twilio" module. To use the module's objects directly:
- Import the module as follows:
import cdata.twilio as mod
- To establish a connection string, call the connect() method from the connector object using an appropriate connection string, such as:
mod.connect("AccountSid=MyAccountSid;AuthToken=MyAuthToken;")
Connecting to Twilio
You can authenticate to Twilio using either an Auth Token or an API key.Auth Token
You can authenticate to Twilio using an Auth Token and an Account SID.
Open the Twilio Console Dashboard, navigate to the Account Info section, and set these connection properties:
- AccountSID: the value of the Account SID field.
- AuthToken: the value of the Auth Token field. Click Show to unhide it.
API Key
To authenticate to Twilio using an API key:
- Open the Twilio Console Dashboard and click Account Info > API Keys > Go to API Keys. The API keys & tokens page opens.
- Click Create API key. The Create new API key menu opens.
- Set Friendly name to a name you want to use to refer to the token.
- Set Region to the region in which you want the API key to apply.
- Set Key type to your desired key type. The options include:
- Standard - Grants access to all Twilio API features except for managing API Keys, Account Configuration, and Subaccounts.
- Main - Grants access to the same features as the Standard key type, with the added ability to manage API Keys, Account Configuration, and Subaccounts.
- Restricted - Allows granular access to a subset of the Twilio API features that the standard APIKey grants. If you select this option, you must manually specify the permissions that the token grants.
- Click Create. This opens the Copy secret key page.
- Note the values of the SID and Secret fields. The latter is only shown once, so make sure you copy it before leaving this page.
- Set the following connection properties:
- AuthScheme: APIKey
- AccountSID: the value of the Account SID field in the Account Info section of the Twilio Console Dashboard.
- APIKeySID: the SID of the API key you generated earlier, which you noted in step 4.
- APIKeySecret: the API key secret of the API key you generated earlier, which you noted in step 4.