我试图向API发出请求:https://www.trakomatic.com/
使用的代码:
import requests
url = 'https://webapi.trakomatic.com/....'
head1 = {'Authorization': 'access_token 066bf0a8d74xxxx'}
head2 = {'Authorization': '066bf0a8d74xxxx'}
head3 = {'Authorization': 'Token : 066bf0a8d74xxxx'}
head4 = {"Token":"066bf0a8d74xxxx"}
response = requests.post(url, headers= head3)
API需要一个令牌来生成HTTP请求。当前我正在使用API提供的令牌,可能即将过期。我得到以下错误。你知道吗
>>>response.text
u'{"Status":"ERROR","Message":"Invalid or NULL token","Data":null}'
>>>response
<Response [200]>
我试过各种格式的标题,因为我怀疑这可能是原因,但没有结果。 有没有一种方法可以让我使用用户名和密码来生成令牌?我做的有什么问题吗?你知道吗
API的身份验证页包含以下内容:
URL Format[web api server]/account/authenticate/
URLhttps://webapi.trakomatic.com/account/authenticate/
Parameter(s){ LoginName: , Password: }
尝试使用请求:
from requests.auth import HTTPBasicAuth
u = 'xxx'
p = 'xxx'
>>>
a=requests.post('https://webapi.trakomatic.com/account/authenticate/', auth=HTTPBasicAuth('u', 'p'))
>>> a
<Response [200]>
>>> a.json()
{u'Status': u'ERROR', u'LoginName': None, u'CorporationId': 0, u'Token': None, u'Msg': u'Invalid information to login', u'Password': None}
用靓汤解决了问题:
相关问题 更多 >
编程相关推荐