【问题标题】:I can't openning a session in ALM 12.5x我无法在 ALM 12.5x 中打开会话
【发布时间】:2018-07-16 17:18:15
【问题描述】:

我是 ALM 的新手。我刚刚阅读了一些来自 REST API 的指南并尝试重复这一点。但我正视情况。在我的最后一个请求中,我有 401 返回(用户未通过身份验证)。我做错了什么?

import requests
from requests.auth import HTTPBasicAuth

url = "https://almalmqc1250saastrial.saas.hpe.com"
login = "+++++++"
password = "+++++"
cookies = dict()
headers = {}

r = requests.get(url + "/qcbin/rest/is-authenticated")
print(r.status_code, r.headers.get('WWW-Authenticate'))

r = requests.get(url + "/qcbin/authentication-point/authentication",
             auth=HTTPBasicAuth(login, password), headers=headers)
print(r.status_code, r.headers)

cookie = r.headers.get('Set-Cookie')
LWSSO_COOKIE_KEY = cookie[cookie.index("=") + 1: cookie.index(";")]
cookies['LWSSO_COOKIE_KEY'] = LWSSO_COOKIE_KEY
print(cookies)

r = requests.post(url + "/qcbin/rest/site-session", cookies=cookies)
print(r.status_code, r.headers)

【问题讨论】:

  • 您确定用户名和密码都正确吗?如果您手动登录,它们可以工作吗?
  • 是的,我确定我的登录名和密码。

标签: python alm hp-quality-center


【解决方案1】:

找到了解决方案。问题是 URL 不正确。要进行身份验证,您需要此 URL:

url_log = "https://login.software.microfocus.com/msg/actions/doLogin.action"

你需要这个标题:

self.__headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        'Host': 'login.software.microfocus.com'
    }

接下来是验证的 POST 请求:

r = self.__session.post(self.url_log, data=self.input_auth, headers=self.__headers)

数据在哪里:

self.input_auth = 'username=' + login + '&' + 'password=' + password

【讨论】:

    猜你喜欢
    • 2016-08-12
    • 1970-01-01
    • 1970-01-01
    • 2013-03-09
    • 1970-01-01
    • 2011-10-20
    • 2014-07-26
    • 2020-11-16
    • 1970-01-01
    相关资源
    最近更新 更多