print source lang-javascript"><code>var watson = require('watson-developer-cloud');

var authorization = watson.authorization({
  username: '&lt;username>',
  password: '&lt;password>',
  version: 'v1'
});

var params = {
  // URL of the resource you wish to access
  url: 'https://stream.watsonplatform.net/text-to-speech/api'
};

authorization.getToken(params, function (err, token) {
  if (!token) {
    console.log('error:', err);
  } else {
    // Use your token here
  }
});</code></pre><h3>Concept Insight