MCPcopy Create free account
hub / github.com/aws/aws-cli / _protected_refresh

Method _protected_refresh

awscli/botocore/credentials.py:590–627  ·  view source on GitHub ↗
(self, is_mandatory)

Source from the content-addressed store, hash-verified

588 self._protected_refresh(is_mandatory=True)
589
590 def _protected_refresh(self, is_mandatory):
591 # precondition: this method should only be called if you've acquired
592 # the self._refresh_lock.
593 try:
594 metadata = self._refresh_using()
595 except Exception:
596 period_name = 'mandatory' if is_mandatory else 'advisory'
597 logger.warning(
598 "Refreshing temporary credentials failed "
599 "during %s refresh period.",
600 period_name,
601 exc_info=True,
602 )
603 if is_mandatory:
604 # If this is a mandatory refresh, then
605 # all errors that occur when we attempt to refresh
606 # credentials are propagated back to the user.
607 raise
608 # Otherwise we'll just return.
609 # The end result will be that we'll use the current
610 # set of temporary credentials we have.
611 return
612 self._set_from_data(metadata)
613 self._frozen_credentials = ReadOnlyCredentials(
614 self._access_key, self._secret_key, self._token, self._account_id
615 )
616 if self._is_expired():
617 # We successfully refreshed credentials but for whatever
618 # reason, our refreshing function returned credentials
619 # that are still expired. In this scenario, the only
620 # thing we can do is let the user know and raise
621 # an exception.
622 msg = (
623 "Credentials were refreshed, but the "
624 "refreshed credentials are still expired."
625 )
626 logger.warning(msg)
627 raise RuntimeError(msg)
628
629 @staticmethod
630 def _expiry_datetime(time_str):

Callers 1

_refreshMethod · 0.95

Calls 2

_set_from_dataMethod · 0.95
_is_expiredMethod · 0.95

Tested by

no test coverage detected