@@ -37,13 +37,23 @@ const renderRequest = async markdown => {
3737 } ;
3838
3939 try {
40- // Create a Google Auth client with the Renderer service url as the target audience.
41- if ( ! client ) client = await auth . getIdTokenClient ( serviceUrl ) ;
42- // Fetch the client request headers and add them to the service request headers.
43- // The client request headers include an ID token that authenticates the request.
44- const clientHeaders = await client . getRequestHeaders ( ) ;
45- serviceRequestOptions . headers [ 'Authorization' ] =
46- clientHeaders [ 'Authorization' ] ;
40+ // [END cloudrun_secure_request]
41+ // If we're in the test environment, use the envvar instead
42+ if ( process . env . ID_TOKEN ) {
43+ serviceRequestOptions . headers [ 'Authorization' ] =
44+ 'Bearer ' + process . env . ID_TOKEN ;
45+ } else {
46+ // [START cloudrun_secure_request]
47+ // Create a Google Auth client with the Renderer service url as the target audience.
48+ if ( ! client ) client = await auth . getIdTokenClient ( serviceUrl ) ;
49+ // Fetch the client request headers and add them to the service request headers.
50+ // The client request headers include an ID token that authenticates the request.
51+ const clientHeaders = await client . getRequestHeaders ( ) ;
52+ serviceRequestOptions . headers [ 'Authorization' ] =
53+ clientHeaders [ 'Authorization' ] ;
54+ // [END cloudrun_secure_request]
55+ }
56+ // [START cloudrun_secure_request]
4757 } catch ( err ) {
4858 throw Error ( 'could not create an identity token: ' + err . message ) ;
4959 }
0 commit comments