Get an AccessKey pair
When you use OpenAPI Explorer to manage HTTPDNS, you need an AccessKey pair to call API operations. An AccessKey pair consists of an AccessKey ID and an AccessKey secret.
To ensure the security of cloud services, you must create a RAM user, get an AccessKey pair for the RAM user, and manage HTTPDNS as the RAM user through OpenAPI Explorer. Follow these steps:
Create a RAM user. For more information, see Create a RAM user.
Get the AccessKey pair of the RAM user. For more information, see Create an AccessKey.
NoteAn AccessKey pair consists of an AccessKey ID and an AccessKey secret.
Install the SDK
You can use the pip tool:
pip install aliyun-python-sdk-httpdnsYou can also download the SDK packages:
Sample code
Before you call the operation, you must configure environment variables and get access credentials from the environment variables. Configuration method:
export CC_AK_ENV=<access_key_id> export CC_SK_ENV=<access_key_secret>Replace <access_key_id> with the AccessKey ID of your RAM user and <access_key_secret> with the AccessKey Secret.
from aliyunsdkcore import client
from aliyunsdkhttpdns.request.v20160201.ListDomainsRequest import ListDomainsRequest
// Configure the SDK profile
// The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using RAM users to make API calls is highly recommended.
// We recommend that you do not save your AccessKey pair (AccessKey ID and AccessKey secret) in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account may be compromised.
// In this example, the system reads the AccessKey pair from environment variables to implement authentication for API access.
String accessKeyId = System.getenv("CC_AK_ENV"); /* Access Key ID */
String accessKeySecret = System.getenv("CC_SK_ENV"); /* Access Key Secret */
clt = client.AcsClient(accessKeyId, accessKeySecret, 'cn-hangzhou')
request = ListDomainsRequest()
result = clt.do_action(request)
print(result)