title: How to authenticate against Spring Security from Android app?
body: <p>I'm building a WebApp using Spring. It is secured by Spring Security and should be accessed from an Android app too. In the web-version i'm using a basic login page.</p>
  
  <p>To authenticate from Android i plan to just send an http request to the standard authentication url /j_spring_security_check with the credentials. And then allways send the cookie with every new request to stay authenticated.</p>
  
  <p>Because the whole WebApp should only be accessed by logged in users, it is necessary to login at every startup of a Session. I tried to send the described Request via a simple html formular:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;&lt;title&gt;Test&lt;/title&gt;&lt;/head&gt;
      &lt;body&gt;
          &lt;form action="http://localhost:8080/livefeedback/j_spring_security_check" method="post"&gt;
              &lt;input type="text", name="j_username" /&gt;&lt;br /&gt;
              &lt;input type="password" name="jpassword" /&gt;&lt;br /&gt;
              &lt;input type="submit" /&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>For the sake of clarity: I want to send a http request from the android app similar to the one generated by sending this html form.</p>
  
  <p>But I am just redirected to my standard login page. I think it's because I have to receive a session id from spring before attempting to login. And I'm not shure if there is a better way to login from the android app.</p>
  
  <p>Here is my http configuration in spring-security.xml:</p>
  
  <pre><code>&lt;http use-expressions="true" auto-config="true"&gt;
          &lt;intercept-url pattern="/login"
              access="permitAll"/&gt;
          &lt;access-denied-handler /&gt;
          &lt;form-login login-page="/login" default-target-url="/"/&gt;
          &lt;logout /&gt;
  &lt;/http&gt;
  </code></pre>
  
  <p>thanking you in anticipation for every hint!</p>