def get_token(): user_agent = request.headers.get('User-Agent', "") device_sn = request.headers.get('device_sn', "") os_platform = request.headers.get('os_platform', "") app_version = request.headers.get('app_version', "") data = request.get_json() sign = data.get('sign', "") expected_sign = utils.get_sign(user_agent, device_sn, os_platform, app_version) if expected_sign != sign: result = { 'success': False, 'msg': "Authorization failed!" } response = make_response(json.dumps(result), 403) else: token = utils.gen_random_string(16) token_dict[device_sn] = token result = { 'success': True, 'token': token } response = make_response(json.dumps(result)) response.headers["Content-Type"] = "application/json" return response
def prepare_headers(self, data=""): token = api_server.TOKEN random_str = utils.gen_random_string(5) authorization = utils.gen_md5([token, data, random_str]) headers = {'authorization': authorization, 'random': random_str} return headers
def prepare_headers(self, data=""): token = api_server.TOKEN data = utils.handle_req_data(data) random_str = utils.gen_random_string(5) authorization = utils.gen_md5(token, data, random_str) headers = { 'authorization': authorization, 'random': random_str } return headers
def get_authenticated_headers(self): user_agent = 'iOS/10.3' device_sn = utils.gen_random_string(15) os_platform = 'ios' app_version = '2.8.6' token = self.get_token(user_agent, device_sn, os_platform, app_version) headers = { 'device_sn': device_sn, 'token': token } return headers
def get_token(): user_agent = request.headers.get('User-Agent', "") device_sn = request.headers.get('device_sn', "") os_platform = request.headers.get('os_platform', "") app_version = request.headers.get('app_version', "") data = request.get_json() sign = data.get('sign', "") expected_sign = utils.get_sign(user_agent, device_sn, os_platform, app_version) if expected_sign != sign: result = {'success': False, 'msg': "Authorization failed!"} response = make_response(json.dumps(result), 403) else: token = utils.gen_random_string(16) token_dict[device_sn] = token result = {'success': True, 'token': token} response = make_response(json.dumps(result)) response.headers["Content-Type"] = "application/json" return response
def get_token(): result = {'success': True, 'token': utils.gen_random_string(8)} response = make_response(json.dumps(result)) response.headers["Content-Type"] = "application/json" return response