title: Download google location history using http request
body: <p>I'm trying to write a c# code that downloads the kml file from <a href="https://maps.google.com/locationhistory/b/0" rel="nofollow noreferrer">https://maps.google.com/locationhistory/b/0</a></p>
  
  <p>I wrote the following code, but the http response I get back brings me to the login page even though </p>
  
  <pre><code>        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://maps.google.com/locationhistory/b/0/kml?startTime=1373666400000&amp;endTime=1373752800000");
  
          request.Credentials = new NetworkCredential("username", "password");
          HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  
          // Get the stream associated with the response.
          Stream receiveStream = response.GetResponseStream();
  
          // Pipes the stream to a higher level stream reader with the required encoding format. 
          StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
  
          using (StreamWriter outfile = new StreamWriter(@"temp.kml"))
          {
              outfile.Write(readStream.ReadToEnd());
          }
  
          response.Close();
          readStream.Close();
  </code></pre>
  
  <p>I try to pass the user credentials.
  I already tried these solutions : 
  - <a href="https://stackoverflow.com/questions/19764113/how-to-use-httpwebrequest-credentials-property-for-basic-authentication">How to use HttpWebRequest.Credentials Property for Basic Authentication?</a>
  - <a href="https://stackoverflow.com/questions/4334521/c-sharp-webrequest-authentication">C# HttpWebRequest using Basic authentication</a>
  but nothing worked.</p>
  
  <p>Does anybody knows how to pass the google credentials, and has experienced google location history api?</p>
  
  <p>Thanks!</p>