title: HTTP Google Login - Cookie turned off
body: <p>I'm trying to log in to my Google account. I have read in older posts to use <a href="https://addons.mozilla.org/de/firefox/addon/httpfox/" rel="nofollow">HTTP-Fox</a> to get all parameters. So I added all, including the hidden ones.</p>
  
  <pre><code>package com.businessLogic;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  import java.util.List;
  import org.apache.http.HttpResponse;
  import org.apache.http.NameValuePair;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.entity.UrlEncodedFormEntity;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.message.BasicNameValuePair;
  
  public class Browser {
   public static void main (String [] arg ){
  
      HttpClient client = new DefaultHttpClient();
      HttpPost post = new HttpPost("https://accounts.google.com/ServiceLogin");
      try {
          List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(1);
          nameValuePairs.add(new BasicNameValuePair("service", "lso"));
          nameValuePairs.add(new BasicNameValuePair("passive", "1209600"));
          nameValuePairs.add(new BasicNameValuePair("continue", "https://accounts.google.com/o/oauth2/auth?....."));
          nameValuePairs.add(new BasicNameValuePair("ltmpl", "embedded"));
          nameValuePairs.add(new BasicNameValuePair("shdf", "CoMBCxIRdGhpcmR...."));
          nameValuePairs.add(new BasicNameValuePair("scc", "1"));
          nameValuePairs.add(new BasicNameValuePair("dsh", "-2602464068824153107"));
          nameValuePairs.add(new BasicNameValuePair("GALX", "qqYU2P_8USM"));
          nameValuePairs.add(new BasicNameValuePair("pstMsg", "1"));
          nameValuePairs.add(new BasicNameValuePair("dnConn", ""));
          nameValuePairs.add(new BasicNameValuePair("checkConnection", "youtube:816:1"));
          nameValuePairs.add(new BasicNameValuePair("checkedDomains", "youtube"));
          nameValuePairs.add(new BasicNameValuePair("timeStmp", ""));
          nameValuePairs.add(new BasicNameValuePair("secTok", ""));
          nameValuePairs.add(new BasicNameValuePair("_utf8", "â"));
          nameValuePairs.add(new BasicNameValuePair("bgresponse", "!A0LfAt2vXHmPiURq..."));
          nameValuePairs.add(new BasicNameValuePair("Email", "XXX"));
          nameValuePairs.add(new BasicNameValuePair("Passwd", "XXX"));
          nameValuePairs.add(new BasicNameValuePair("signIn", "Anmelden"));
  
          post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
          HttpResponse response = client.execute(post);
          BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
          String line = "";
          while ((line = rd.readLine()) != null) {
              System.out.println(line);
          }   
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  }
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;title&gt;Google Accounts&lt;/title&gt;
  &lt;/head&gt;
  &lt;body dir="ltr" bgcolor="#ffffff" text="#000000" link="#0000cc" vlink="#551a8b" alink="#ff0000"&gt;
  &lt;div class="topbar aligns" style="font-size:smaller; margin-bottom:0 15px 1px 15px; white-space:nowrap;"&gt;
          &lt;a&gt;
                Google Home
  &lt;/a&gt;
  |
  
  &lt;a&gt;Sign in&lt;/a&gt;&lt;/div&gt;
  &lt;div class="header margins" style="height: 40px; margin: 13px 15px 9px 15px;"&gt;&lt;a href="https://accounts.google.com/"&gt;&lt;img src="/googleaccountslogo/en.gif" border="0" class="floats-normal" alt="Google"&gt;&lt;/a&gt;
  &lt;/div&gt;
  &lt;div style="clear:both;"&gt;&lt;/div&gt;
  &lt;div class="body"&gt;&lt;p&gt;Your browser&amp;#39;s cookie functionality is turned off. Please turn it on.
  [&lt;a href="http://www.google.com/support/accounts/bin/answer.py?answer=61416&amp;amp;hl=en&amp;amp;ctx=ch_ServiceLogin&amp;amp;p=lso" target="_blank"&gt;?&lt;/a&gt;]&lt;/p&gt;
  &amp;copy;2012 Google
  
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>The login failed. The "Sign-In" option is also available. I have no idea how to handle these Answer / Cookies. 
  I can't find useful solutions because everyone uses the old API where the <code>httpclient</code> was a part of the <code>org.apache.common.*</code>.</p>
  
  <p>So can you help me? </p>