Terence – thanks for this information!

I am able to retrieve the curl command for a Timeline URL encoded to obtain the location data for a particular day. In it are all of the header (-H) fields including the cookie. The cookie itself has many sub-parameters as mentioned in other replies to this post.

I also found this post which has some Python code which can be used to download a KML. The code references a similar method of retrieving the cookie.

What I don’t understand is how to “save off” the cookie details. Should it be stored as plain text in a variable? Should if be store in a text file and referenced in that manner (I’m thinking of how my browser’s cookies get stored and used). I simply do not have the knowledge or experience regarding use of cookies to comprehend this “cookie topic” in any detail.

I actually am trying to create a slight variation of this technique. I have two Google accounts for which I want to look up the current location. Right now I have location history enabled and only turned on for the mobile device associated with each account. Interactively, I want to log on to one of those accounts, retrieve the latest location history (i.e., today’s KML), and then parse it to get the latest logged location for that account.

I’d love to be able to programmatically log in to a particular Google account (a simple snippet of Python code) becoming user ‘0’, fire off the Timeline KML HTTP request, collect the resulting output, and then use a KML parsing library (e.g., http://pythonhosted.org/pykml/). Worst case, I suppose I could log in to each account, save off that account’s specific cookie and then use the appropriate cookie depending on which account I’ve logged in. Ideally I’d like to pass the authentication information directly to the Timeline HTTP request but I haven’t gotten that to work properly even interactively. Ideally, ideally, I’d like to retrieve the cookie programmatically instead of having to store it (and have it go stale).

Another issue I’m having is making my login persistent from the login request to the KML request. Does anyone know how to do that in Python? I’d love some guidance.