修改 我找到了一个解决方案,我通过
解析了Key和TokenMyKey = (LoginResponse.json()['Result']['Key'])
MyToken = (LoginResponse.json()['Result']['Token'])
来自LoginResponse的然后将其添加到RegisterHeaders
RegisterHeaders = {
'accept': "application/json",
'AOToken': MyToken,
'AOKey': MyKey,
'Cache-Control': "no-cache"
}
原始问题:
非常感谢任何形式的帮助!我需要帮助通过Python验证自己。我使用API来获取一些我可以在网站上调用的json函数。登录部分有效,但在我尝试进行身份验证时会出现错误。我使用邮递员,我可以登录并认证我自己。
我必须以某种方式调用登录时获得的令牌,但我怎么称呼它我不知道。希望有人可以帮忙!
现在已经有几天了:/
# Login
import requests
import json
LoginURL = "https://website.com/Login"
LoginCredentials = {"username":"MYUSERNAME","password":"MYPASSWORD"}
LoginHeaders = {
'Cache-Control': "no-cache",
'Postman-Token': "MYPOSTMANTOKEN"
}
LoginResponse = requests.request("GET", LoginURL, headers=LoginHeaders, params=LoginCredentials)
print(LoginResponse.text)
# Register
RegisterURL = "https://website.com/Register"
RegisterCredentials = {"username":"MYUSERNAME"}
RegisterHeaders = {
'Cache-Control': "no-cache",
'Postman-Token': "MY POSTMAN-TOKEN"
}
RegisterResponse = requests.request("GET", RegisterURL, headers=RegisterHeaders, params=RegisterCredentials)
print(RegisterResponse.text)
答案 0 :(得分:0)
我找到了解决方案,我通过
解析了Key和TokenMyKey = (LoginResponse.json()['Result']['Key'])
MyToken = (LoginResponse.json()['Result']['Token'])
来自LoginResponse的然后将其添加到RegisterHeaders
RegisterHeaders = {
'accept': "application/json",
'AOToken': MyToken,
'AOKey': MyKey,
'Cache-Control': "no-cache"
}