All Products
Search
Document Center

Initialization

Last Updated: May 27, 2020

Prerequisites

  • You have registered an Alibaba Cloud account, completed real-name verification, and activated ApsaraVideo for VOD.
  • You have obtained an AccessKey for access to ApsaraVideo for VOD. You can create an AccessKey for your Alibaba Cloud account on the AccessKey management page of the Alibaba Cloud console. Alternatively, you can create a RAM user in the RAM console and grant the user the permission to access ApsaraVideo for VOD. For more information, see RAM user access.

Initialization

The regionId parameter specifies the region of ApsaraVideo for VOD. Set this parameter to cn-shanghai for a region in China.

  1. # -*- coding: UTF-8 -*-
  2. import json
  3. import traceback
  4. from aliyunsdkcore.client import AcsClient
  5. def init_vod_client(accessKeyId, accessKeySecret):
  6. regionId = 'cn-shanghai' # Sets the region of ApsaraVideo for VOD.
  7. connectTimeout = 3 # Sets the connection timeout duration, in seconds.
  8. return AcsClient(accessKeyId, accessKeySecret, regionId, auto_retry=True, max_retry_time=3, timeout=connectTimeout)
  1. # -*- coding: UTF-8 -*-
  2. import json
  3. import traceback
  4. from aliyunsdkcore.client import AcsClient
  5. from aliyunsdkcore.auth.credentials import StsTokenCredential
  6. def init_vod_client(accessKeyId, accessKeySecret, securityToken):
  7. regionId = 'cn-shanghai' # Sets the region of ApsaraVideo for VOD.
  8. connectTimeout = 3 # Sets the connection timeout duration, in seconds.
  9. credential = StsTokenCredential(accessKeyId, accessKeySecret, securityToken)
  10. return AcsClient(region_id=regionId, auto_retry=True, max_retry_time=3, timeout=connectTimeout, credential=credential)