| 2665 | self._feature_ids = ('CREDENTIALS_PROFILE_LOGIN', 'CREDENTIALS_LOGIN') |
| 2666 | |
| 2667 | def load(self): |
| 2668 | loaded_config = self._load_config() |
| 2669 | profiles = loaded_config.get('profiles', {}) |
| 2670 | profile_config = profiles.get(self._profile_name, {}) |
| 2671 | |
| 2672 | if 'login_session' not in profile_config: |
| 2673 | return None |
| 2674 | |
| 2675 | fetcher = LoginCredentialFetcher( |
| 2676 | session_name=profile_config['login_session'], |
| 2677 | token_loader=LoginCredentialsLoader(self._token_cache), |
| 2678 | client_creator=self._client_creator, |
| 2679 | time_fetcher=_local_now, |
| 2680 | feature_ids=self._feature_ids, |
| 2681 | ) |
| 2682 | |
| 2683 | register_feature_ids(self._feature_ids) |
| 2684 | |
| 2685 | # Return the current cached credentials initially, |
| 2686 | # regardless if they're expired |
| 2687 | cached_credentials = fetcher.load_cached_credentials() |
| 2688 | |
| 2689 | return RefreshableCredentials( |
| 2690 | access_key=cached_credentials['access_key'], |
| 2691 | secret_key=cached_credentials['secret_key'], |
| 2692 | token=cached_credentials['token'], |
| 2693 | expiry_time=_parse_if_needed(cached_credentials['expiry_time']), |
| 2694 | account_id=cached_credentials['account_id'], |
| 2695 | method=self.METHOD, |
| 2696 | refresh_using=fetcher.refresh_credentials, |
| 2697 | time_fetcher=_local_now, |
| 2698 | ) |