File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ const GOOGLE_AUTH_TOKEN_PATH = '/o/oauth2/token';
2929
3030// NOTE: the Google Metadata Service uses HTTP over a vlan
3131const GOOGLE_METADATA_SERVICE_HOST = 'metadata.google.internal' ;
32- const GOOGLE_METADATA_SERVICE_PATH = '/computeMetadata/v1beta1 /instance/service-accounts/default/token' ;
32+ const GOOGLE_METADATA_SERVICE_PATH = '/computeMetadata/v1 /instance/service-accounts/default/token' ;
3333
3434const configDir = ( ( ) => {
3535 // Windows has a dedicated low-rights location for apps at ~/Application Data
@@ -351,6 +351,9 @@ export class MetadataServiceCredential implements Credential {
351351 const request : HttpRequestConfig = {
352352 method : 'GET' ,
353353 url : `http://${ GOOGLE_METADATA_SERVICE_HOST } ${ GOOGLE_METADATA_SERVICE_PATH } ` ,
354+ headers : {
355+ 'Metadata-Flavor' : 'Google' ,
356+ } ,
354357 httpAgent : this . httpAgent ,
355358 } ;
356359 return requestAccessToken ( this . httpClient , request ) ;
Original file line number Diff line number Diff line change @@ -337,6 +337,12 @@ describe('Credential', () => {
337337 return c . getAccessToken ( ) . then ( ( token ) => {
338338 expect ( token . access_token ) . to . equal ( 'anAccessToken' ) ;
339339 expect ( token . expires_in ) . to . equal ( 42 ) ;
340+ expect ( httpStub ) . to . have . been . calledOnce . and . calledWith ( {
341+ method : 'GET' ,
342+ url : 'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token' ,
343+ headers : { 'Metadata-Flavor' : 'Google' } ,
344+ httpAgent : undefined ,
345+ } ) ;
340346 } ) ;
341347 } ) ;
342348 } ) ;
You can’t perform that action at this time.
0 commit comments