【发布时间】:2021-05-12 23:53:17
【问题描述】:
我正在运行一个 openapi3 服务器,我正在尝试对其进行身份验证。
我可以用curl 做到这一点,没有任何问题
curl -k -X POST "https://localhost:8787/api/login/user" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"username\":\"admin\",\"password\":\"admin\"}"
#and i get the token back
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNjEyODY3NDU3LCJleHAiOjE2MTI4NzEwNTd9.9eFgomcpJbinN7L4X1VOHfZGvJeUvHiv6WPjslba1To
但是当使用python 时,我只得到响应代码 (200),没有包含令牌的数据
这是我的python脚本
import requests
import os
url = str(os.environ.get('API_SERVER_URL'))+'login/user'
head = {'accept': 'application/json', 'Content-Type': 'application/json'}
data = {"username": "admin", "password": "admin"} }
response = requests.post(url, json=data, headers=head, verify=False)
print(response)
我得到的只是 200 响应
<Response [200]>
【问题讨论】:
标签: python-3.x http python-requests httpresponse