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

前提条件

初始化

点播服务的接入区域请参见接入区域和标识,例如:接入区域在上海,请使用cn-shanghai
  • 填入账号AccessKey信息,进行初始化。示例如下:
    var RPCClient = require('@alicloud/pop-core').RPCClient;
    
    function initVodClient(accessKeyId, accessKeySecret,) {
        var regionId = 'cn-shanghai';   // 点播服务接入区域
        var client = new RPCClient({
            accessKeyId: accessKeyId,
            accessKeySecret: accessKeySecret,
            endpoint: 'http://vod.' + regionId + '.aliyuncs.com',
            apiVersion: '2017-03-21'
        });
    
        return client;
    }
  • 填入STS信息,进行初始化。示例如下:
    var RPCClient = require('@alicloud/pop-core').RPCClient;
    
    function initVodClient(accessKeyId, accessKeySecret, securityToken) {
        var regionId = 'cn-shanghai';   // 点播服务接入区域
        var client = new RPCClient({
            accessKeyId: accessKeyId,
            accessKeySecret: accessKeySecret,
            securityToken: securityToken,
            endpoint: 'http://vod.' + regionId + '.aliyuncs.com',
            apiVersion: '2017-03-21'
        });
    
        return client;
    }