STS Client
安装
npm install @alicloud/sts-sdk
Node.js >= 8.5.0 required.
示例
const StsClient = require('@alicloud/sts-sdk');
const sts = new StsClient({
endpoint: 'sts.aliyuncs.com', // check this from sts console
accessKeyId: '***************', // check this from aliyun console
accessKeySecret: '***************', // check this from aliyun console
});
async function demo() {
const res1 = await sts.assumeRole(`acs:ram::${accountID}:role/${roleName}`, 'xxx');
console.log(res1);
const res2 = await sts.getCallerIdentity();
console.log(res2);
}
demo();