Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better cloudpak support #8

Open
MasterOdin opened this issue Nov 16, 2021 · 0 comments
Open

Better cloudpak support #8

MasterOdin opened this issue Nov 16, 2021 · 0 comments

Comments

@MasterOdin
Copy link
Member

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({});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant