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

Synthesize method does not honor access_token from IAM API Key #93

Merged
merged 1 commit into from
Nov 3, 2018

Conversation

jeancarl
Copy link
Contributor

In SDK v.0.36 with Firefox 60.3.0esr (64-bit), using the new IAM API Key authentication for Text to Speech, the synthesize method filters out the access_token parameter.

var params = {
  text: "Hello",
  voice: "en-US_MichaelVoice",
  access_token: "<ACCESS_TOKEN>"
};

stream = WatsonSpeech.TextToSpeech.synthesize(params);

The requested URI resource doesn't include this access token and the watson-token parameter is undefined, returning a CORS error.

https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=en-US_MichaelVoice&text=Hello&watson-token=**undefined**

There should also be a check that token parameter is defined, given it's either token or access_token.

module.exports = function synthesize(options) {
  if (!options || (!options.token && !options.access_token)) {
    throw new Error('Watson TextToSpeech: missing required parameter: options.token (CF) or options.access_token (RC)');
  }
  options['watson-token'] = options.token;
  delete options.token;
  var audio = options.element || new Audio();
Checklist
  • npm test passes (tip: npm run autofix can correct most style issues)

@CLAassistant
Copy link

CLAassistant commented Oct 31, 2018

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@germanattanasio germanattanasio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for the PR @jeancarl.

@dpopp07 is currently maintaining this repo so I would like him to look at this too.

Copy link
Contributor

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@germanattanasio germanattanasio merged commit 9cf2459 into watson-developer-cloud:master Nov 3, 2018
@watson-github-bot
Copy link
Member

🎉 This PR is included in version 0.35.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

5 participants