Skip to content

Commit

Permalink
Reload bearer token from disk to work with kubernetes bound-service-a…
Browse files Browse the repository at this point in the history
…ccount-tokens
  • Loading branch information
grosser committed Jan 20, 2022
1 parent 3616496 commit 0da3a04
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,6 @@ def _get_setting(name, default):
# 'bearer_token_auth' should be enabled.
config['bearer_token_path'] = instance.get('bearer_token_path', default_instance.get('bearer_token_path', None))

# The service account bearer token to be used for authentication
config['_bearer_token'] = self._get_bearer_token(config['bearer_token_auth'], config['bearer_token_path'])

config['telemetry'] = is_affirmative(instance.get('telemetry', default_instance.get('telemetry', False)))

# The metric name services use to indicate build information
Expand Down Expand Up @@ -415,7 +412,9 @@ def get_http_handler(self, scraper_config):

headers = http_handler.options['headers']

bearer_token = scraper_config['_bearer_token']
# The service account bearer token to be used for authentication
# this needs to be reloaded from it's path in case the token was refreshed
bearer_token = self._get_bearer_token(scraper_config['bearer_token_auth'], scraper_config['bearer_token_path'])
if bearer_token is not None:
headers['Authorization'] = 'Bearer {}'.format(bearer_token)

Expand Down

0 comments on commit 0da3a04

Please sign in to comment.