阿里云首页 智能媒体生产

初始化

本篇文档为您介绍了如何使用账号AccessKey以及STS的示例代码进行Python SDK初始化。

前提条件

初始化

智能媒体生产服务的接入区域请参见服务接入区域及访问域名,例如:接入区域在上海,请使用cn-shanghai

  1. 填入账号AccessKey信息,进行初始化。如何生成AccessKey, 详情见创建RAM用户并授权。示例如下:

# -*- coding: UTF-8 -*-
from alibabacloud_ice20201109.client import Client
from alibabacloud_tea_openapi.models import Config

def init_ice_client_ak(access_key_id, access_key_secret):
    endpoint = "ice.cn-shanghai.aliyuncs.com"
    region_id = 'cn-shanghai'  # 智能媒体生产服务接入区域
    connect_timeout = 3000  # 连接超时,单位为毫秒
    config = Config(
        access_key_id=access_key_id,
        access_key_secret=access_key_secret,
        region_id=region_id,
        endpoint=endpoint,
        connect_timeout=connect_timeout,
        type='access_key'
    )
    return Client(config)

init_ice_client_ak('<your-access-key>', '<your-access-secret>')

  1. 填入账号STS信息,进行初始化。如何生成STS,详情见创建角色并进行STS临时授权。示例如下:

# -*- coding: UTF-8 -*-
from alibabacloud_ice20201109.client import Client
from alibabacloud_tea_openapi.models import Config

def init_ice_client_sts(access_key_id, access_key_secret, security_token):
    endpoint = "ice.cn-shanghai.aliyuncs.com"
    region_id = 'cn-shanghai'  # 智能媒体生产服务接入区域
    connect_timeout = 3000  # 连接超时,单位为毫秒    
    config = Config(
        access_key_id=access_key_id,
        access_key_secret=access_key_secret,
        security_token=security_token,
        region_id=region_id,
        endpoint=endpoint,
        connect_timeout=connect_timeout,
        type='sts'
    )
    return Client(config)

init_ice_client_sts('<your-access-key>', '<your-access-secret>', '<your-security-token>')