我无法在 ALM 12.5x 中打开会话

I can't openning a session in ALM 12.5x

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

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)

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

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

你需要这个 headers:

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