使用 Python 个请求的 Cookie 身份验证错误

Cookie authentication error using Python requests

我正在尝试 POST 使用“/api/console/proxy”路径向 Kibana 发出请求。 我的请求中有 3 headers:

es_headers = {
                'kbn-version': "5.5.0",
                'Content-Type': "application/json",
                'Cookie': "session_2=eyJhbGciOi....(long string)"
            }

我正在使用 Python 请求如下:

session = requests.Session()
r = session.post(url, timeout=15, data=json.dumps(body), headers=es_headers)

从 "Postman" 它工作得很好,但是从我的 Python 脚本我得到一个 [200] 响应,但响应的内容是这样的:

'Error encountered = Unable to decrypt session details from cookie. So clearing it.'

我用谷歌搜索了这个回复,但找不到任何相关信息(这很奇怪……) 任何帮助在这里表示赞赏 谢谢

尝试将 cookie 与 headers 分开,像这样:

import requests 

es_headers = {
    'kbn-version': "5.5.0",
    'Content-Type': "application/json",
    }

session = requests.Session()
session.cookies.update({'Cookie': "session_2=eyJhbGciOi....(long string)"})

r = session.post(url, timeout=15, data=json.dumps(body), headers=es_headers)

希望这对您有所帮助