如何解决Python 请求:“缺少授权标头”
我正在尝试使用 Python 的请求为 Ubisoft 制作用户名检查器。 当我运行我的代码时,我总是得到一个状态代码 200,它应该表明用户名可用,即使用户名被占用。我检查了 request link,它说:
{"moreInfo":"","errorCode":3,"httpCode":401,"errorContext":"Shipyard.Profiles.Services","message":"缺少授权头","environment" :"prod","additionalDetails":{},"transactionTime":"2021-05-24T17:27:50.9065561Z","transactionId":"5d4edaf2-8e8f-4e3f-9736-fce6aea82e32"}
但是,我将 'Authorization':token
添加到我的代码中,令牌是您登录后从权威网站获得的输入。
我的代码:
import requests
import json
def check():
username = input("What name to check? :")
print(" ")
token = input("Enter token: ")
r = requests.get("https://public-ubiservices.ubi.com/v2/profiles?nameOnPlatform=" + username + "&platformType=uplay",headers = {
'Method':'GET','Authority':'public-ubiservices.ubi.com','Ubi-AppId':'c5393f10-7ac7-4b4f-90fa-21f8f3451a04','Authorization': token,'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/90.0.4430.212 Safari/537.36','Ubi-RequestedplatformType':'uplay',})
print(r.status_code)
print(r.text)
print("Press ENTER to start checking")
input("")
check()
编辑:添加 r.text
r.text 将此作为应采用的用户名(用户名 = 测试)的输出
200
{"profiles":[{"profileId":"21067093-822e-497d-ae8a-5d171573f6c8","userId":"21067093-822e-497d-ae8a-5d171573f6c8","platformType":"uplay","idOnPlatform":"21067093-822E-497D-AE8A-5D171573F6C8","nameOnPlatform":"test"}]}
和 r.text 将其作为应该可用的用户名(用户名 = test815581m)的输出
200
{"profiles":[]}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。