def refresh(self): print("start refresh token...") request = QueryTokenForMnsQueueRequest() request.set_MessageType(msgtype) # 数据提交方式 # smsRequest.set_method(MT.POST) # 数据提交格式 # smsRequest.set_accept_format(FT.JSON) response = acs_client.do_action_with_exception(request) # print response if response is None: raise ServerException("GET_TOKEN_FAIL", "获取token时无响应") #response = response.decode('utf-8') response_body = json.loads(response.decode('utf-8')) if response_body.get("Code") != "OK": raise ServerException("GET_TOKEN_FAIL", "获取token失败") self.__tmp_access_key = response_body.get("MessageTokenDTO").get("AccessKeySecret") self.__tmp_access_id = response_body.get("MessageTokenDTO").get("AccessKeyId") self.__expire_time = response_body.get("MessageTokenDTO").get("ExpireTime") self.__token = response_body.get("MessageTokenDTO").get("SecurityToken") print("key=%s, id=%s, expire_time=%s, token=%s" \ % (self.__tmp_access_key, self.__tmp_access_id, self.__expire_time, self.__token)) print("finsh refresh token...")
def refresh(self): print("start refresh token...") request = QueryTokenForMnsQueueRequest() request.set_MessageType(msgtype) # 数据提交方式 # smsRequest.set_method(MT.POST) # 数据提交格式 # smsRequest.set_accept_format(FT.JSON) response = acs_client.do_action_with_exception(request) # print response if response is None: raise ServerException("GET_TOKEN_FAIL", "获取token时无响应") #response = response.decode('utf-8') response_body = json.loads(response.decode('utf-8')) if response_body.get("Code") != "OK": raise ServerException("GET_TOKEN_FAIL", "获取token失败") self.__tmp_access_key = response_body.get("MessageTokenDTO").get( "AccessKeySecret") self.__tmp_access_id = response_body.get("MessageTokenDTO").get( "AccessKeyId") self.__expire_time = response_body.get("MessageTokenDTO").get( "ExpireTime") self.__token = response_body.get("MessageTokenDTO").get( "SecurityToken") print(("key=%s, id=%s, expire_time=%s, token=%s" \ % (self.__tmp_access_key, self.__tmp_access_id, self.__expire_time, self.__token))) print("finsh refresh token...")
def refresh(self): print "start refresh token..." request = QueryTokenForMnsQueueRequest() request.set_MessageType(msgtype) response = acs_client.do_action_with_exception(request) # print response if response is None: raise ServerException("GET_TOKEN_FAIL", "获取token时无响应") response_body = json.loads(response) if response_body.get("Code") != "OK": raise ServerException("GET_TOKEN_FAIL", "获取token失败") self.__tmp_access_key = response_body.get("MessageTokenDTO").get( "AccessKeySecret") self.__tmp_access_id = response_body.get("MessageTokenDTO").get( "AccessKeyId") self.__expire_time = response_body.get("MessageTokenDTO").get( "ExpireTime") self.__token = response_body.get("MessageTokenDTO").get( "SecurityToken") print "finsh refresh token..."
def refresh(self): logger.info(f'{self.tk_desc} start refresh token ...') request = QueryTokenForMnsQueueRequest() request.set_MessageType(self.queue_cfg.msg_type) request.set_QueueName(self.queue_cfg.queue_name) response = acs_client.do_action_with_exception(request) logger.info(f'{self.tk_desc} QueryTokenForMnsQueueRequest response: {response}') if response is None: raise ServerException('GET_TOKEN_FAIL', f'{self.tk_desc} 获取token时无响应') response_body = json.loads(response) if response_body.get('Code') != 'OK': raise ServerException('GET_TOKEN_FAIL', f'{self.tk_desc} 获取token失败') sts_token = response_body.get('MessageTokenDTO') self.tmp_access_key = sts_token.get('AccessKeySecret') self.tmp_access_id = sts_token.get('AccessKeyId') self.expire_time = sts_token.get('ExpireTime') self.token = sts_token.get('SecurityToken') logger.info(f'{self.tk_desc} finish refresh token')