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
- An Alibaba Cloud account is created. To create an Alibaba Cloud account, visit the account registration page. Real-name verification is completed. ApsaraVideo VOD is activated.
- An AccessKey pair is created to call ApsaraVideo VOD operations. You can create the AccessKey pair of your Alibaba Cloud account in the User Management console. Alternatively, you can create a RAM user in the RAM console and grant the RAM user the permissions on ApsaraVideo VOD. For more information, see Create and grant permissions to a RAM user.
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, accessKeySecret,) { var regionId = 'cn-shanghai'; // The region where you want to call ApsaraVideo VOD operations. var client = new RPCClient({ accessKeyId: accessKeyId, accessKeySecret: accessKeySecret, 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, accessKeySecret, securityToken) { var regionId = 'cn-shanghai'; // The region where you want to call ApsaraVideo VOD operations. var client = new RPCClient({ accessKeyId: accessKeyId, accessKeySecret: accessKeySecret, securityToken: securityToken, endpoint: 'http://vod.' + regionId + '.aliyuncs.com', apiVersion: '2017-03-21' }); return client; }