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';
29
29
30
30
// NOTE: the Google Metadata Service uses HTTP over a vlan
31
31
const 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' ;
33
33
34
34
const configDir = ( ( ) => {
35
35
// Windows has a dedicated low-rights location for apps at ~/Application Data
@@ -351,6 +351,9 @@ export class MetadataServiceCredential implements Credential {
351
351
const request : HttpRequestConfig = {
352
352
method : 'GET' ,
353
353
url : `http://${ GOOGLE_METADATA_SERVICE_HOST } ${ GOOGLE_METADATA_SERVICE_PATH } ` ,
354
+ headers : {
355
+ 'Metadata-Flavor' : 'Google' ,
356
+ } ,
354
357
httpAgent : this . httpAgent ,
355
358
} ;
356
359
return requestAccessToken ( this . httpClient , request ) ;
Original file line number Diff line number Diff line change @@ -337,6 +337,12 @@ describe('Credential', () => {
337
337
return c . getAccessToken ( ) . then ( ( token ) => {
338
338
expect ( token . access_token ) . to . equal ( 'anAccessToken' ) ;
339
339
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
+ } ) ;
340
346
} ) ;
341
347
} ) ;
342
348
} ) ;
You can’t perform that action at this time.
0 commit comments