This topic describes how to install the STS SDK for Node.js. It also provides an example about how to use the SDK.

Install the STS SDK for Node.js

Run the following npm command: npm install -S @alicloud/pop-core.

Use the STS SDK for Node.js

  Usage: npm install -S @alicloud/pop-core
  powered by alinode (

const Core = require('@alicloud/pop-core');
// Construct an Alibaba Cloud client. The client will be used to send a request.
// When you construct the client, set the AccessKey ID and AccessKey secret.
var client = new Core({
  accessKeyId: '<accessKeyId>',
  accessKeySecret: '<accessKeySecret>',
  endpoint: '',
  apiVersion: '2015-04-01'

// Specify the Alibaba Cloud Resource Name (ARN) of the RAM role and the role session name. You can also specify a policy to grant the returned STS token fewer permissions than those granted to the RAM role.
var params = {
  'RoleArn': '<role-arn>',
  'RoleSessionName': 'session-name',
  'Policy': '<policy>'

// Construct an AssumeRole request.
client.request('AssumeRole', params).then((result) => {
}, (ex) => {
  • For the list of STS endpoints in different regions, see Endpoints.
  • For more information about the AssumeRole API operation, see AssumeRole.