1

This is the HTML body of the site, which I want to log in:

<body onload="setFocusOnLoginForm();">
    <div class="login-container">
        <div class="login-header">
            <h2>OSS Аргус</h2>
        </div>
        <div class="login-content">
        <form method="post" action="j_security_check" name="loginform"
            id="loginform" target="_parent" style="padding: 2px;">

        <table align="center" class=loginTable>

                    <tr class="form-field">
                        <td><label for="j_username" style="white-space: nowrap;">Логин</label></td>
                        <td><input type="text" name="j_username" id="j_username" size="12"
                            value=""/>
                        </td>
                    </tr>

                    <tr class="form-field">
                        <td><label for="j_password" style="white-space: nowrap;">Пароль</label></td>
                        <td><input type="password" name="j_password" id="j_password" value="" size="12" /></td>
                    </tr>

                    <tr>
                        <td/>
                        <td><input type="submit" value="LOGIN" class="login-button" /></td>
                    </tr>

        </table>


        </form>
        </div>
    </div>



</body>

Here is my code for login:

protected Void doInBackground(Void... params) {

        Document doc = null;
        Document arg = null;
        try {


            disableSSLCertCheck();
            Connection.Response loginForm = Jsoup.connect("https://URL/home.seam")
                    .data("j_username", "USERNAME", "j_password", "PASSWORD", "login-button", "LOGIN")
                    .followRedirects(true)
                    .method(Connection.Method.POST)
                    .execute();
            doc = Jsoup.connect("https://URL/home.seam")
                    .userAgent("Chrome")
                    .cookies(loginForm.cookies())
                    .get();
            /*    doc = Jsoup.connect("https://URL/taskList.seam")
                    .userAgent("Mozilla")
                    .get();*/

        } catch (IOException e) {

            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (KeyManagementException e) {
            e.printStackTrace();
        }

What's wrong? I can't login

I've just read Logging in to website programatically Android but in my site is not such parameters especially login-button.

Community
  • 1
  • 1
Alex
  • 101
  • 2
  • 10

1 Answers1

0

You may be missing some headers.

Try to login with your favorite browser and sniff the headers it sends.

Once you have the list of those headers, add them in your code.

Stephan
  • 40,082
  • 60
  • 228
  • 319