コード例 #1
0
def login_refresh_token():
    """
    登录刷新token保存到本地
    :return:
    """
    try:
        response = requests.post(
            url=
            "https://app-beta.jike.ruguoapp.com/1.0/users/loginWithPhoneAndPassword",
            headers=local_headers(),
            data=json.dumps({
                "mobilePhoneNumber": "00000000001",
                "password": "******",
                "areaCode": "+86"
            }))

        token = {
            "x-jike-access-token": response.headers.get('x-jike-access-token'),
            "x-jike-refresh-token":
            response.headers.get('x-jike-refresh-token')
        }
        jikeToken.save_token(token)

    except requests.exceptions.RequestException:
        print('HTTP Request failed')
コード例 #2
0
def refresh_tokens():
    """
    app_auth_tokens.refresh刷新token,保存到本地
    :return:
    """
    try:
        response = requests.post(
            url="https://app.jike.ruguoapp.com/1.0/app_auth_tokens.refresh",
            headers={
                "x-jike-device-id":
                "4DA0BE6A-69D6-4C3B-BCD3-A77310872F36",
                "x-jike-refresh-token":
                jikeToken.get_token().get('x-jike-refresh-token')
            },
        )

        token = {
            "x-jike-access-token": response.headers.get('x-jike-access-token'),
            "x-jike-refresh-token":
            response.headers.get('x-jike-refresh-token')
        }
        jikeToken.save_token(token)

    except requests.exceptions.RequestException:
        print('HTTP Request failed')
コード例 #3
0
def register_refresh_token():
    """
    注册刷新token保存到本地
    :return: 
    """
    #生成16位随机密码
    length = 16
    chars = string.ascii_letters + string.digits
    paw = ''.join([choice(chars) for _ in range(length)])

    data = json.dumps({"username": str(uuid.uuid4()).upper(), "password": paw})

    try:
        response = requests.post(
            url="https://app-beta.jike.ruguoapp.com/1.0/users/register",
            headers=local_headers(),
            data=data)

        token = {
            "x-jike-access-token": response.headers.get('x-jike-access-token'),
            "x-jike-refresh-token":
            response.headers.get('x-jike-refresh-token')
        }
        jikeToken.save_token(token)

    except requests.exceptions.RequestException:
        print('HTTP Request failed')
コード例 #4
0
    def tearDown(self):
        time.sleep(1)
        if self.response.status_code == 200:
            token = {
                "x-jike-access-token":
                self.response.headers.get('x-jike-access-token'),
                "x-jike-refresh-token":
                self.response.headers.get('x-jike-refresh-token')
            }
            jikeToken.save_token(token)
        else:
            pass

        self.log.build_case_line(self.case_name, str(self.response))
        print("测试结束,输出log完结\n\n")