Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Better cloudpak support #8

@MasterOdin

Description

@MasterOdin

code:

const { BearerTokenAuthenticator, CloudPakForDataAuthenticator } = require("ibm-cloud-sdk-core");
 
let tts;
const watsonInfo = io.config.get('watson') || null;
console.log('watsonInfo is: ' + JSON.stringify(watsonInfo));
if (watsonInfo && watsonInfo.environment == 'cloudpak') {
  logger.info('environment is cloudpak (token)');
  tts = new TextToSpeechV1({
    authenticator: new BearerTokenAuthenticator({
      bearerToken: watsonInfo.bearerToken,
    }),
    disableSslVerification: true,
    serviceUrl: watsonInfo.ttsURL,
  });
}
else if (watsonInfo && watsonInfo.environment == "cloudpak-user-pass") {
  logger.info('environment is cloudpak-user-pass');
  tts = new TextToSpeechV1({
    authenticator: new CloudPakForDataAuthenticator({
      username: watsonInfo.username,
      password: watsonInfo.password,
      disableSslVerification: true,
      url: watsonInfo.ttsUserPassURL + '/icp4d-api'
    }),
    disableSslVerification: true,
    serviceUrl: watsonInfo.ttsUserPassURL + watsonInfo.ttsUserPassPath
  });
}
else {
  logger.info('environment is ibmcloud');
  tts = new TextToSpeechV1({});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions