Google maps location sharing problems

let us know how it goes. for me i saw improvement immediately after I deleted my google shared account cookies from my browser after i exported the cookie.

Alright, so I tested removing cookies, for me, google maps location sharing does not work without the following minimum set of cookies:

  1. __Secure-1PSID
  2. __Secure-3PSID
  3. __Secure-1PSIDTS

I can NOT get rid of the 1PSIDTS cookie that seems to be the root of the problems here. This seems to be the same as what yall are saying when I reread your comments.

So now the next question is if I can delete the google cookies from my local machine I pulled these cookies from and see how long the maps works for. I’ve set up an alert to let me know when a shared user is no longer being updated, so I’ll know shortly after the cookie expires/stops being valid.

When I tried to delete all cookies from google from the browser for the shared account, it seems to have invalidated my cookies that HASS was using and it doesn’t work.

Making another account to ask my friends to share with is a bit ridiculous. Wonder if the solution is to keep a specific version of chrome in a VM or something that is ONLY used for pulling these cookies…

if you use browser’s inbuilt cookie deletion (specially in chrome) there is a possibility that it will log you out (not confirmed). I use an extension called ‘editthiscookie’ which worked perfectly and cookies are still working after deletion.

basic idea is that once you have exported you do not use these cookies anywhere, except in haas. my theory is if you let browser logged into this google account, there are some javascripts which will execute at some events and update cookies and invalidating earlier cookies. However, when you are using haas (locationsharinglib) then there is no javascript, so cookies survive their lifetime.

can you please share the alert which you setup to monitor when location doesn’t update ? I would like to set that up too.

Having some inconsistent results. This worked for about a week but then HA decided my cookies were no good. When I use ‘editthiscookie’ to delete all my cookies, I found my test script failed (Same as @jonofmac reported ) This time, I’ve tried just deleting __Secure-1PSID & __Secure-3PSID to see how it gets on.

that’s strange. deleting the cookies shouldn’t expire them. i can think of two possibility

  1. there was a race condition and google updated the cookies between your export and deletion
  2. in my non scientific experiments, cookies seem to last longer if i logged in google maps and then clicked on each person’s location. if i just logged in google maps and exported the cookies (without checking the locations of other members) then exported cookies won’t work that well.

Mine stopped working after 24 hours again. Logged in this morning and it’s no longer working. Deleting the cookies logged me out of chrome/google. When I log back in, my other cookies got immediately invalidated.

Let me try this using a completely separate browser which I will use for NOTHING but to get these cookies…

Edit: Alright, I fired up edge and logged into google maps. I literally never use edge so this should be a fine test. Let’s see what happens in a day :slight_smile:

Logged in this morning and it’s no longer working. Deleting the cookies logged me out of chrome/google.

Yes deleting the cookies will be log you out of ‘browser’. That is the intent. Your exported cookies are still valid. Idea is that you do not let browser touch those cookies. If you login again in browser, google is killing your previous cookies. Try these steps.

  1. Log into google maps using browser
  2. Go to each member who is sharing their location in google map to see their location (this is just for good measure, not sure if it has any impact. for me it brought good luck)
  3. Export your cookies and import into haas except __Secure-1PSIDTS.
  4. Delete your cookies using ‘edit this cookie’
  5. DO NOT log into same google account from anywhere again.

If I delete secure 1PSIDTS, it doesn’t seem to work for me. It won’t look in. I do delete secure 3 PSIDTS

Here’s an update, it’s been 2 days so far and my cookies I grabbed in edge (a browser I never use), is working still.

Update: after I took the cookies using a browser I do not use (from the same common account), I am still logged in with home assistant. That makes almost 2 weeks now without getting logged out.

I normally use chrome but I opened Firefox and logged in and grabbed cookies and haven’t opened Firefox since.

1 Like

My final update unless something changes, but as of October 15 (coming up on 2 months since I created the cookie file in a different browser I never use), my home assistant is STILL logged in and getting location information from google.

So at least for me, it appears that simply using a browser you never use (in my case, edge) to export the cookies allows the cookies to stay valid for a long time since the browser never is opened and goes to a page where google will update the cookie values.
I literally did nothing beyond opening edge, logging into google maps, and exporting my cookies. Closed edge, and I haven’t opened it since.

1 Like

I just started having issues with this as well. Great timing right after Life360 goes down.

I figured the cookie just expired like it has a few times before. So I opened up Firefox (browser I never use), navigated to maps.google.com, signed in to the shared-to account, pulled the cookie, replaced the cookie and rebooted. I got “new sign in” notifications for that account when HA rebooted but the entities still aren’t updating.

Any tips?

EDIT: Got it. Guess I just had to keep trying until I got a cookie that took. :person_shrugging:
EDIT 2: Spoke too soon. Rebooted to get Life360 fixed and Google Maps broke again. Uggh

I believe there is a possibility of fixing the problem of expiring cookies. This fix is based on observation that when using browser, it never logs out which indicates that before old cookies have expired, by that time server has already sent updated cookies so a client can watch for new cookies and keep updating self. I am not very good with python so if anyone want to contribute, that will be awesome. Here are two high level changes -

  1. locationsharing lib implements a callback when cookies change. This callback is called with new cookie.
  2. Homeassistant provides the callback to locationsharinglib and stores the new cookies as returned by callback and uses that cookie to call locationsharing lib that point onwards

thoughts ?

The Alexa Media Player integration used to constantly deal with having to re-authenticate to update the cookie. They’ve since been able to get it to continuously update and I can’t remember the last time I had to re-authenticate that one. Plus they moved it to GUI.

With Life360 giving us issues again, it would be a great time for perfecting the Google Maps integration. And with a simpler authentication/cookie flow and no need for YAML it could be very popular. Unfortunately I don’t have the skillset to do it.

4 Likes

The exact steps are explained here by @pnbruckner. This worked for me the first try.

1 Like

I do plan to make some improvements to the Google Maps integration, specifically adding UI based config flow, converting it from a “legacy” tracker (that uses known_devices.yaml) to the newer entity-based style, add device info, and possibly making the cookie file name a bit more flexible.

Unfortunately, I don’t know much about how cookie files, and websites in general, work to help with improving the authentication/authorization part. I don’t have the skillset to do that. :slightly_frowning_face:

3 Likes

I also plan to update the doc with this more detailed procedure, probably after first trying it out with Google Chrome & Firefox as well.

3 Likes

This procedure worked for me. I didn’t use HA companion app on other devices but shared their location to the google account. Then on the user account on HA I used their device to track. This gave me the location of my family devices on the map in HA. Hope it works fine.

1 Like

From experience, what is key is to immediately close the browser after capturing the cookie file. If you don’t, the cookie you got quickly gets invalidated by new requests done in the background by the page.

1 Like

Stopped working now. Just check and the device location is 4 days old. So seems like I have to get the cookie file again.

Still working for me with a cookie dated Jan 20 for my main account. The expiration date says 2026.

The cookie file for my “dedicated” google account dates 2022 and is still going (until May 2024 from the expiration date).