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;
1717let username = process . env . SPEECH_TO_TEXT_USERNAME ;
1818let 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.
2124let 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 } ) ;
You can’t perform that action at this time.
0 commit comments