2

I'm trying to write a c# code that downloads the kml file from https://maps.google.com/locationhistory/b/0

I wrote the following code, but the http response I get back brings me to the login page even though

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://maps.google.com/locationhistory/b/0/kml?startTime=1373666400000&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();

I try to pass the user credentials. I already tried these solutions : - How to use HttpWebRequest.Credentials Property for Basic Authentication? - C# HttpWebRequest using Basic authentication but nothing worked.

Does anybody knows how to pass the google credentials, and has experienced google location history api?

Thanks!

Community
  • 1
  • 1
ilanak
  • 97
  • 1
  • 10

0 Answers0