I have looked at multiple examples on stackoverflow and cannot get it to work.
This is the url I need to log into programmtically:http://powerschool.fortschools.org/public/
I have tried many different ways but am unsuccessfully. Heres what I have currently:
Original Url before logging in: http://powerschool.fortschools.org/public/
Url after logging in: http://powerschool.fortschools.org/guardian/home.html
Form I think is submitted before login:
<form action="/guardian/home.html" method="post" name="LoginForm" target="_top" id="LoginForm" onsubmit="doPCASLogin(this);">
<input type="hidden" name="pstoken" value="308732667SkW2oaVnhxqIqM5PzqdGWrXW4jdQoB8W">
<input type="hidden" name="contextData" value="2AA011214C3F506D76216C5B459574636E2269F51AC438EB11081A7C735345A8">
<input type="hidden" name="dbpw" value="">
<input type="hidden" name="translator_username" value="">
<input type="hidden" name="translator_password" value="">
<input type="hidden" name="translator_ldappassword" value="">
<input type="hidden" name="returnUrl" value="">
<input type="hidden" name="serviceName" value="PS Parent Portal">
<input type="hidden" name="serviceTicket" value="">
<input type="hidden" name="pcasServerUrl" value="/">
<input type="hidden" name="credentialType" value="User Id and Password Credential">
<h2>Parent Sign In</h2>
<!--box content-->
<div id="noscript" class="feedback-alert" style="display: none;"> To sign in to PowerSchool, you must use a browser that supports and has JavaScript enabled. </div>
<fieldset id="login-inputs" class="group">
<div>
<label>Username</label>
<input type="text" id="fieldAccount" name="account" value="" size="39">
</div>
<div>
<label>Password</label>
<input type="password" name="pw" value="" size="39"><div id="login-help"><a href="/public/account_recovery_begin.html">Having trouble signing in?</a></div>
</div>
<div id="translatorInput" style="display: none;">
<label>Translator Sign In</label>
<input type="password" name="translatorpw" value="" size="39">
</div>
<div class="button-row">
<button type="submit" id="btn-enter" title="Sign In To PowerSchool Parent Access" value="Enter" border="0">Sign In</button>
</div>
</fieldset>
<!-- box content-->
</form>
After pressing the submit button the form changes to this (only the dbpw changes, (this was two seperate examples so the pstoken and the contextData did change)):
This is after you "fully log in"
Here is my code (not working):
public static final String POWERSCHOOLLOGINURL = "http://powerschool.fortschools.org/public/";
public static final String POWERSCHOOLLOGIN = "http://powerschool.fortschools.org/guardian/home.html";
public static void main(String[] args) throws IOException {
Map<String, String> nameToVal = new HashMap<String, String>();
nameToVal.put("pstoken", "308732667b2uBDHKHeNJc1XTXdgDSVwxzHfzldM9M");
nameToVal.put("contextData", "e1c94866f2ed77f3ae37bc1a2a477631");
nameToVal.put("dbpw", "29e3fdf45f7959a5e0c894ad01b34941");
nameToVal.put("translator_username", "");
nameToVal.put("translator_password", "");
nameToVal.put("translator_ldappassword", "");
nameToVal.put("returnUrl", "");
nameToVal.put("serviceName", "PS Parent Portal");
nameToVal.put("serviceTicket", "");
nameToVal.put("pcasServerUrl", "/");
nameToVal.put("credentialType", "User Id and Password Credential");
nameToVal.put("account", "horvste");
nameToVal.put("translatorpw", "");
nameToVal.put("returnUrl", "");
nameToVal.put("pcasServerUrl", "/");
nameToVal.put("credentialType", "User Id and Password Credential");
Map<String, String> cookies = new HashMap<String, String>();
cookies.put("JSESSIONID", "2C108FB2394FFE097E366BC3C34827B8");
cookies.put("lastHref",
"http%3A%2F%2Fpowerschool.fortschools.org%2Fguardian%2Fhome.html");
cookies.put("uiStateCont", "null");
cookies.put("uiStateNav", "null");
Document doc = Jsoup.connect(POWERSCHOOLLOGIN).cookies(cookies)
.data(nameToVal).method(Method.POST).post();
System.out.println(doc.toString());
}
note: HtmlUnit is not an acceptable answer (it's to slow and doesn't work on android).