Skip to content

Commit e86a8e4

Browse files
Merge pull request #3 from watson-developer-cloud/stage1
Promote stage1 to master
2 parents da11d6b + 8a9e456 commit e86a8e4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

app.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ let bearerToken = process.env.SPEECH_TO_TEXT_BEARER_TOKEN;
1717
let username = process.env.SPEECH_TO_TEXT_USERNAME;
1818
let password = process.env.SPEECH_TO_TEXT_PASSWORD;
1919

20+
// On Cloud Foundry, we'll have a VCAP_SERVICES environment variable with credentials.
21+
let vcapCredentials = vcapServices.getCredentials('speech_to_text');
22+
2023
// Create appropriate token manager.
2124
let tokenManager;
22-
if (apikey) {
23-
// If we're using IAM, it's possible that we're running on Cloud Foundry, where we need to look at the VCAP_SERVICES.
24-
const vcapCredentials = vcapServices.getCredentials('speech_to_text');
25-
if (vcapCredentials) {
26-
apikey = vcapCredentials.apikey || apikey;
27-
url = vcapCredentials.url || url;
28-
}
25+
if (vcapCredentials || apikey) {
26+
// Choose credentials from VCAP if they exist.
27+
apikey = (vcapCredentials && vcapCredentials.apikey) || apikey;
28+
url = (vcapCredentials && vcapCredentials.url) || url;
2929

3030
try {
3131
tokenManager = new IamTokenManager({ apikey });

0 commit comments

Comments
 (0)