Obtains the access credentials to cloud services.


This function returns a Promise object, through which a temporary credential for accessing cloud services is obtained. The credential is updated every 15 minutes by default. Therefore, you can call this function to obtain the updated credential when you want to access a cloud service. The format of the credential is as follows:
Parameter Type Description
accessKeyId String The AccessKey ID. The AccessKey pair consists of an AccessKey ID and an AccessKey secret. You can use the AccessKey pair to authenticate API requests that you make to Alibaba Cloud.
accessKeySecret String The AccessKey secret.
securityToken String The STS token.

Sample requests

This topic describes the usage of the CredentialProviderChain().resolvePromise() method. The sample code is as follows:
Note For detailed description of the sample code for accessing OSS, see Access Alibaba Cloud OSS.
'use strict';

var leSdk = require('linkedge-core-sdk');
var credChain= new leSdk.CredentialProviderChain();
var OSS = require('./node_modules/ali-oss');

exports.handler = function (event, context, callback) {
  // Retrieves group role credential.
    .then((cred) => {
      console.log('Access Key Id: %s, Access Key Secret: %s, Security Token: %s',
        cred.accessKeyId, cred.accessKeySecret, cred.securityToken);

      // Constructs a client to interact with OSS cloud service.
      var client = new OSS({
        accessKeyId: cred.accessKeyId,
        accessKeySecret: cred.accessKeySecret,
        stsToken: cred.securityToken,
        region: 'oss-cn-shanghai',
        bucket: 'le-fc-bucket',

      /* Upload local file to cloud. */
      return client.put('fileFromEdge.txt', "/linkedge/run/localFile.txt");
    .then((result) => {
    .catch((err) => {