The software development kits (SDKs) for all supported languages use a Client class as the entry point. To construct an instance of this class, you must specify configuration information, including an endpoint and an AccessKey pair.
Configure an endpoint
When you use the SDK, you must determine the region where your project resides, such as China (Hangzhou), and then select the corresponding endpoint to initialize the Client. For a list of endpoints, see Endpoints.
When you set the endpoint for the Client, ensure that the region of your project matches the region of the endpoint. Otherwise, the SDK cannot access the specified project.
You can specify an endpoint only when you construct a Client instance. To access projects in different regions, you must construct a separate Client instance for each region using its corresponding endpoint.
Configure an access credential
To access the Alibaba Cloud Intelligent Media Management service, you need a valid access credential for signature authentication. The following three types of credentials are supported:
The AccessKey ID and AccessKey secret of an Alibaba Cloud account. To obtain them, perform the following steps:
WarningIf the AccessKey pair for your Alibaba Cloud account is leaked, all your cloud resources are at risk. We recommend that you use an AccessKey pair from a Resource Access Management (RAM) user to perform operations. This practice reduces the risk of leaks.
Register an Alibaba Cloud account on the official Alibaba Cloud website.
Create an AccessKey ID and an AccessKey secret. For more information, see Obtain an AccessKey pair.
The AccessKey ID and AccessKey secret of a RAM user who has permissions to use the Intelligent Media Management service. To obtain them, perform the following steps:
Log on to the RAM console with your Alibaba Cloud account.
Create a new RAM user or use an existing one.
Use your Alibaba Cloud account to grant the RAM user permissions to access the Intelligent Media Management service.
Create an AccessKey ID and an AccessKey secret for the RAM user. For more information, see Obtain an AccessKey pair.
Temporary access credentials that are obtained from Security Token Service (STS). To obtain them, perform the following steps:
Use the STS service to generate a temporary AccessKey ID, AccessKey secret, and security token. For more information, see AssumeRole.
Use the temporary credentials to access the Intelligent Media Management service.
Integration Initialization
To use an Intelligent Media Management SDK, you must first create a Client instance. You can then call the methods of the instance to access the Intelligent Media Management service.
This section describes how to install the Intelligent Media Management SDK for Python V1.27.4 and create a Client instance to access a project in the China (Hangzhou) region.
To use IMM API V2020-09-30, you must use IMM SDK V2020-09-30.
Install the SDK
Run the following command to install the SDK:
pip install alibabacloud_imm20200930Create a Client
The following sample code shows how to create a Client:
from alibabacloud_imm20200930.client import Client as imm20200930Client from alibabacloud_tea_openapi import models as open_api_models import os cred = Client(config) config = Config( type='access_key', access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID'), access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET'), ) # Specify the endpoint. config.endpoint = f'imm.cn-hangzhou.aliyuncs.com' client = imm20200930Client(config)