If there is are credentials in the configuration associated with the session, use those.
(self)
| 1441 | self._config_parser = config_parser |
| 1442 | |
| 1443 | def load(self): |
| 1444 | """ |
| 1445 | If there is are credentials in the configuration associated with |
| 1446 | the session, use those. |
| 1447 | """ |
| 1448 | try: |
| 1449 | full_config = self._config_parser(self._config_filename) |
| 1450 | except ConfigNotFound: |
| 1451 | return None |
| 1452 | if self._profile_name in full_config['profiles']: |
| 1453 | profile_config = full_config['profiles'][self._profile_name] |
| 1454 | if self.ACCESS_KEY in profile_config: |
| 1455 | logger.info( |
| 1456 | "Credentials found in config file: %s", |
| 1457 | self._config_filename, |
| 1458 | ) |
| 1459 | access_key, secret_key = self._extract_creds_from_mapping( |
| 1460 | profile_config, self.ACCESS_KEY, self.SECRET_KEY |
| 1461 | ) |
| 1462 | token = self._get_session_token(profile_config) |
| 1463 | account_id = self._get_account_id(profile_config) |
| 1464 | register_feature_id('CREDENTIALS_PROFILE') |
| 1465 | return Credentials( |
| 1466 | access_key, |
| 1467 | secret_key, |
| 1468 | token, |
| 1469 | method=self.METHOD, |
| 1470 | account_id=account_id, |
| 1471 | ) |
| 1472 | else: |
| 1473 | return None |
| 1474 | |
| 1475 | def _get_session_token(self, profile_config): |
| 1476 | for token_name in self.TOKENS: |