请求:Python Post Request仅返回错误代码400

时间:2019-02-14 05:11:19

标签: python python-3.x python-requests

(我是刚开始堆栈溢出的新手,请告诉我一些改进的技巧) 我最近接触了python请求,并且对与python相关的网络内容有些陌生,所以如果它有些愚蠢,那就不要惹我。我一直在尝试许多方法来使我的发布事件之一不返回错误400。我弄乱了标题和数据以及许多其他内容,而我得到的代码是404或400。

我尝试向项目添加一堆标题。我正在尝试登录制作自动购买机器人的网站“ Roblox”。 Csrf令牌不在cookie中,因此我发现了一个漏洞,该漏洞通过向注销url发送请求来获取令牌(如果有人感到困惑)。我也仔细检查了我输入的数据,确实是正确的。我正在研究多个小时,但找不到解决方法,因此我第一次来堆栈溢出。

RobloxSignInDeatils = { 
    "cvalue": "TestWebDevAcc", #Username
    "ctype": "Username", #Leave Alone
    "password": "Test123123" #Password
}

def GetToken(Session, Headers):
    LogoutUrl = "https://api.roblox.com/sign-out/v1" #Url to get CSRF
    Request = Session.post(LogoutUrl, Headers) #Sent Post
    print("Token: ", Request.headers["X-CSRF-TOKEN"]) #Steal the token
    return Request.headers["X-CSRF-TOKEN"] #Return Token

with requests.session() as CurrentSession:
    Header = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36"
    } #Get the UserAgent Header Only
    CurrentSession.get("https://www.roblox.com/login", headers=Header) #Send to the login page
    CsrfToken = GetToken(CurrentSession, Header) #Get The Token

    Header["X-CSRF-TOKEN"] = CsrfToken #Set the token
    SignIn = CurrentSession.post("https://auth.roblox.com/v2/login",
                                 data=RobloxSignInDeatils, headers=Header) # Send Post to Sign in
    print(SignIn.status_code) #Returns 400 ? 

打印“ print(SignIn.status_code)”仅返回400,没有其他解释

编辑:如果这有帮助,请列出所有标题的列表:

Request URL: https://auth.roblox.com/v2/login
Request Method: OPTIONS
Status Code: 200 OK
Remote Address: 128.116.112.44:443
Referrer Policy: no-referrer-when-downgrade
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: X-CSRF-TOKEN,Content-Type,Pragma,Cache-Control,Expires
Access-Control-Allow-Methods: OPTIONS, TRACE, GET, HEAD, POST, DELETE, PATCH
Access-Control-Allow-Origin: https://www.roblox.com
Access-Control-Max-Age: 600
Cache-Control: max-age=120, private
Content-Length: 0
Date: Thu, 14 Feb 2019 04:04:13 GMT
P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
Roblox-Machine-Id: CHI1-WEB2875
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Access-Control-Request-Headers: content-type,x-csrf-token
Access-Control-Request-Method: POST
Connection: keep-alive
Host: auth.roblox.com
Origin: https://www.roblox.com
Referer: https://www.roblox.com/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36
Payload:
{cvalue: "TestWebDevAcc", ctype: "Username", password: "Test123123"}

0 个答案:

没有答案
相关问题