Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_session_ak_and_sk(self):
request = GetSessionAkRequest()
request.set_method("GET")
request.set_duration_seconds(self._session_period)
try:
response_str = self._sts_client.do_action_with_exception(request)
response = json.loads(response_str.decode('utf-8'))
session_ak = str(response.get("SessionAccessKey").get("SessionAccessKeyId"))
session_sk = str(response.get("SessionAccessKey").get("SessionAccessKeySecret"))
self._session_credential = session_ak, session_sk
except exceptions.ServerException as srv_ex:
if srv_ex.error_code == 'InvalidAccessKeyId.NotFound' or srv_ex.error_code == 'SignatureDoesNotMatch':
raise exceptions.ClientException(error_code.SDK_INVALID_CREDENTIAL,
error_msg.get_msg('SDK_INVALID_CREDENTIAL'))
else:
raise