All Products
Search
Document Center

Initialization

Last Updated: Jul 11, 2019

Prerequisites

Initialization

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

# -*- coding: UTF-8 -*-
import json
import traceback
from aliyunsdkcore.client import AcsClient

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

def init_vod_client(accessKeyId, accessKeySecret, securityToken):
    regionId = 'cn-shanghai' # Sets the region of ApsaraVideo for VOD.
    connectTimeout = 3 # Sets the connection timeout duration, in seconds.
    credential = StsTokenCredential(accessKeyId, accessKeySecret, securityToken)
    return AcsClient(region_id=regionId, auto_retry=True, max_retry_time=3, timeout=connectTimeout, credential=credential)