alibabacloud_credentials/provider/rsa_key_pair.py [109:134]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if response.status_code != 200:
            raise CredentialException(
                f'error refreshing credentials from rsa_key_pair, http_code: {response.status_code}, result: {response.body.decode("utf-8")}')

        dic = json.loads(response.body.decode('utf-8'))
        if 'SessionAccessKey' not in dic:
            raise CredentialException(
                f'error retrieving credentials from rsa_key_pair result: {response.body.decode("utf-8")}')

        cre = dic.get('SessionAccessKey')
        if 'SessionAccessKeyId' not in cre or 'SessionAccessKeySecret' not in cre:
            raise CredentialException(
                f'error retrieving credentials from rsa_key_pair result: {response.body.decode("utf-8")}')

        # 先转换为时间数组
        time_array = time.strptime(cre.get('Expiration'), '%Y-%m-%dT%H:%M:%SZ')
        # 转换为时间戳
        expiration = calendar.timegm(time_array)
        credentials = Credentials(
            access_key_id=cre.get('SessionAccessKeyId'),
            access_key_secret=cre.get('SessionAccessKeySecret'),
            expiration=expiration,
            provider_name=self.get_provider_name()
        )
        return RefreshResult(value=credentials,
                             stale_time=_get_stale_time(expiration))
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



alibabacloud_credentials/provider/rsa_key_pair.py [158:183]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if response.status_code != 200:
            raise CredentialException(
                f'error refreshing credentials from rsa_key_pair, http_code: {response.status_code}, result: {response.body.decode("utf-8")}')

        dic = json.loads(response.body.decode('utf-8'))
        if 'SessionAccessKey' not in dic:
            raise CredentialException(
                f'error retrieving credentials from rsa_key_pair result: {response.body.decode("utf-8")}')

        cre = dic.get('SessionAccessKey')
        if 'SessionAccessKeyId' not in cre or 'SessionAccessKeySecret' not in cre:
            raise CredentialException(
                f'error retrieving credentials from rsa_key_pair result: {response.body.decode("utf-8")}')

        # 先转换为时间数组
        time_array = time.strptime(cre.get('Expiration'), '%Y-%m-%dT%H:%M:%SZ')
        # 转换为时间戳
        expiration = calendar.timegm(time_array)
        credentials = Credentials(
            access_key_id=cre.get('SessionAccessKeyId'),
            access_key_secret=cre.get('SessionAccessKeySecret'),
            expiration=expiration,
            provider_name=self.get_provider_name()
        )
        return RefreshResult(value=credentials,
                             stale_time=_get_stale_time(expiration))
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



