Hallo!
Ich möchte mich an einer Webseite via jsoup einloggen, aber erhalte immer Error 400.
Wenn ich das einloggen in Chrom anschaue, erhalte ich:
mit den Post Daten:
In jsoup erhalte ich aber:
mein Code:
Ich möchte mich an einer Webseite via jsoup einloggen, aber erhalte immer Error 400.
Wenn ich das einloggen in Chrom anschaue, erhalte ich:
Code:
Request URL: https://company.com/account/login/sTarget/account/sTargetAction/index
Request Method: POST
Status Code: 302
Remote Address: 71.71.214.35:443
Referrer Policy: strict-origin-when-cross-origin
cache-control: no-cache, private
content-length: 0
content-type: text/html; charset=UTF-8
date: Mon, 25 Apr 2022 06:54:12 GMT
location: https://company.com/
server: Apache
set-cookie: session-1=tbe8hd5qo2tf41mo6l79l8d7mh; expires=Mon, 02-May-2022 06:54:13 GMT; Max-Age=604800; path=/; secure; HttpOnly
set-cookie: slt=26629e16-a6b3-4e77-9fd2-c1575f90bc7a.1; expires=Tue, 25-Apr-2023 06:54:13 GMT; Max-Age=31536000; path=/; secure; httponly
set-cookie: nocache=price-1; path=/; secure; httponly
set-cookie: x-cache-context-hash=090ea158954ee6bccdc69bdaf3a53a86216e8489; path=/; secure
vary: User-Agent
x-powered-by: PHP/7.4.28
:authority: company.com
:method: POST
:path: /account/login/sTarget/account/sTargetAction/index
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
cache-control: max-age=0
content-length: 122
content-type: application/x-www-form-urlencoded
cookie: __csrf_token-1=3Yq16LSlPEvnxRS3fnDFClcPYBU3zc; cookieDeclined=1; session-1=p9jv3sk2mordb5fdk57tf4rj9c
origin: https://company.com
referer: https://company.com/account
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: same-origin
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36
mit den Post Daten:
Code:
sTarget: account
email: user@company.com
password: CGyd@7c4sPqpfP
Submit:
__csrf_token: 3Yq16LSlPEvnxRS3fnDFClcPYBU3zc
In jsoup erhalte ich aber:
Java:
org.jsoup.HttpStatusException: HTTP error fetching URL. Status=400, URL=https://company.com/account/login/sTarget/account/sTargetAction/index
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:760)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:705)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:295)
at java.base/java.lang.Thread.run(Thread.java:834)
mein Code:
Java:
try {
res = Jsoup.connect("https://company.com/account/login/sTarget/account/sTargetAction/index")
.data("Submit", "").data("sTarget", "account").data("email", "user@company.com")
.data("password", "CGyd@7c4sPqpfP").method(Method.POST).execute();
} catch (IOException e) {
e.printStackTrace();
return false;
}