This topic describes how to initialize ApsaraVideo VOD SDK for Node.js by using an AccessKey pair or a Security Token Service (STS) token.

Prerequisites

Initialize the SDK

Determine the region where you want to call ApsaraVideo VOD operations. For more information about the supported regions, see Access regions and IDs. For example, if you want to call the operations in the China (Shanghai) region, use cn-shanghai.
  • Use the AccessKey pair to initialize the SDK. Example:
    var RPCClient = require('@alicloud/pop-core').RPCClient;
    
    function initVodClient(accessKeyId, secretAccessKey,) {
        var regionId = 'cn-shanghai';   // The region where you want to call ApsaraVideo VOD operations.
        var client = new RPCClient({
            accessKeyId: accessKeyId,
            secretAccessKey: secretAccessKey,
            endpoint: 'http://vod.' + regionId + '.aliyuncs.com',
            apiVersion: '2017-03-21'
        });
    
        return client;
    }
  • Use an STS token to initialize the SDK. Example:
    var RPCClient = require('@alicloud/pop-core').RPCClient;
    
    function initVodClient(accessKeyId, secretAccessKey, securityToken) {
        var regionId = 'cn-shanghai';   // The region where you want to call ApsaraVideo VOD operations.
        var client = new RPCClient({
            accessKeyId: accessKeyId,
            secretAccessKey: secretAccessKey,
            securityToken: securityToken,
            endpoint: 'http://vod.' + regionId + '.aliyuncs.com',
            apiVersion: '2017-03-21'
        });
    
        return client;
    }