全部产品
云市场

初始化

更新时间:2019-03-01 21:01:27

前置条件

初始化

点播服务的接入区域参考 接入区域标识,如国内请使用cn-shanghai

  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' # 点播服务接入区域
  7. connectTimeout = 3 # 连接超时,单位为秒
  8. return AcsClient(accessKeyId, accessKeySecret, regionId, auto_retry=True, max_retry_time=3, timeout=connectTimeout)
  • 使用 STS 初始化
  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' # 点播服务接入区域
  8. connectTimeout = 3 # 连接超时,单位为秒
  9. credential = StsTokenCredential(accessKeyId, accessKeySecret, securityToken)
  10. return AcsClient(region_id=regionId, auto_retry=True, max_retry_time=3, timeout=connectTimeout, credential=credential)