File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -17,15 +17,15 @@ let bearerToken = process.env.SPEECH_TO_TEXT_BEARER_TOKEN;
17
17
let username = process . env . SPEECH_TO_TEXT_USERNAME ;
18
18
let password = process . env . SPEECH_TO_TEXT_PASSWORD ;
19
19
20
+ // On Cloud Foundry, we'll have a VCAP_SERVICES environment variable with credentials.
21
+ let vcapCredentials = vcapServices . getCredentials ( 'speech_to_text' ) ;
22
+
20
23
// Create appropriate token manager.
21
24
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 ;
29
29
30
30
try {
31
31
tokenManager = new IamTokenManager ( { apikey } ) ;
You can’t perform that action at this time.
0 commit comments