Holds the credentials needed to authenticate requests. In addition, it knows how to refresh itself. :param str access_key: The access key part of the credentials. :param str secret_key: The secret key part of the credentials. :param str token: The security token, valid only for
| 381 | |
| 382 | |
| 383 | class RefreshableCredentials(Credentials): |
| 384 | """ |
| 385 | Holds the credentials needed to authenticate requests. In addition, it |
| 386 | knows how to refresh itself. |
| 387 | |
| 388 | :param str access_key: The access key part of the credentials. |
| 389 | :param str secret_key: The secret key part of the credentials. |
| 390 | :param str token: The security token, valid only for session credentials. |
| 391 | :param function refresh_using: Callback function to refresh the credentials. |
| 392 | :param str method: A string which identifies where the credentials |
| 393 | were found. |
| 394 | :param function time_fetcher: Callback function to retrieve current time. |
| 395 | """ |
| 396 | |
| 397 | # The time at which we'll attempt to refresh, but not |
| 398 | # block if someone else is refreshing. |
| 399 | _advisory_refresh_timeout = _DEFAULT_ADVISORY_REFRESH_TIMEOUT |
| 400 | # The time at which all threads will block waiting for |
| 401 | # refreshed credentials. |
| 402 | _mandatory_refresh_timeout = _DEFAULT_MANDATORY_REFRESH_TIMEOUT |
| 403 | |
| 404 | def __init__( |
| 405 | self, |
| 406 | access_key, |
| 407 | secret_key, |
| 408 | token, |
| 409 | expiry_time, |
| 410 | refresh_using, |
| 411 | method, |
| 412 | time_fetcher=_local_now, |
| 413 | advisory_timeout=None, |
| 414 | mandatory_timeout=None, |
| 415 | account_id=None, |
| 416 | ): |
| 417 | self._refresh_using = refresh_using |
| 418 | self._access_key = access_key |
| 419 | self._secret_key = secret_key |
| 420 | self._token = token |
| 421 | self._account_id = account_id |
| 422 | self._expiry_time = expiry_time |
| 423 | self._time_fetcher = time_fetcher |
| 424 | self._refresh_lock = threading.Lock() |
| 425 | self.method = method |
| 426 | self._frozen_credentials = ReadOnlyCredentials( |
| 427 | access_key, secret_key, token, account_id |
| 428 | ) |
| 429 | self._normalize() |
| 430 | if advisory_timeout is not None: |
| 431 | self._advisory_refresh_timeout = advisory_timeout |
| 432 | if mandatory_timeout is not None: |
| 433 | self._mandatory_refresh_timeout = mandatory_timeout |
| 434 | |
| 435 | def _normalize(self): |
| 436 | self._access_key = botocore.compat.ensure_unicode(self._access_key) |
| 437 | self._secret_key = botocore.compat.ensure_unicode(self._secret_key) |
| 438 | |
| 439 | @classmethod |
| 440 | def create_from_metadata( |
no outgoing calls