コード例 #1
0
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
コード例 #2
0
ファイル: base.py プロジェクト: weiquzwq/ApiTestEngine
    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
コード例 #3
0
    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
コード例 #4
0
    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
コード例 #5
0
ファイル: api_server.py プロジェクト: qinjuan/ApiTestEngine
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
コード例 #6
0
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