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:
- __Secure-1PSID
- __Secure-3PSID
- __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
- there was a race condition and google updated the cookies between your export and deletion
- 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
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.
- Log into google maps using browser
- 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)
- Export your cookies and import into haas except __Secure-1PSIDTS.
- Delete your cookies using âedit this cookieâ
- 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.
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.
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.
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 -
- locationsharing lib implements a callback when cookies change. This callback is called with new cookie.
- 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.
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.
I also plan to update the doc with this more detailed procedure, probably after first trying it out with Google Chrome & Firefox as well.
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.
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.
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).