I am trying to create an App that logs into my schoool's grade servers and displays data. The website I am trying to log into is: "https://portal.mcpsmd.org/public/"
I have written my code according to this stackoverflow question. Here is the relevant code for my specific situation:
Connection.Response loginForm = Jsoup.connect("https://portal.mcpsmd.org/public/")
.method(Connection.Method.GET)
.execute();
Document document = Jsoup.connect("https://portal.mcpsmd.org/guardian/home.html/")
.data("account", "#######")
.data("pw","*******")
.cookies(loginForm.cookies())
.post();
System.out.println(document.title());
The reason I have written my code this way is because when I did "inspect element" on my school's page I saw this:
screenshot of school's inspect element
I can see that my school uses the method "post" and the login request is at "/guardian/home.html"
Many of the Stack Overflow questions I have looked at has told me to use a method like this, where I connect to the login request and send it my username and password as data. Am I going about this correctly at all? I am trying to use JSoup to login to my school's website, so in my mind if I do "document.title()" it should print the name of the page I get once already signing in. This program is only printing the name of the log-in screen page.
I have been working on this project for almost two days now, and initially started with 0 knowledge of JSoup. I would greatly appreciate any explanation on the best way to go about logging into a website using JSoup.