Google Maps Device Tracking Setup?

Hi again @costas

I just created a linux mint VM, installed and updated things for an hour, and succesfully created the cookie file with cookiegettercli. No joy, it keeps telling me the cookie file ¡does not provide a valid session (but, I got the google account alert…). The only thing that half work is the Chrome extension, though the session created only finds the same user that logged in.
I´m a t a loss here…

Hi Augusto,

Cookiegetter should not be used. Can you please try the mozilla add-on to retrieve the cookies since there have been reports that the chrome one does not work on Windows, so it might not work correctly on mint either.

I do have the very same issue. Were you able to fix it?

Reporting back: TOTAL SUCCESS!

Step by Step:
Oracle VM, download and install any linux distro.
Open firefox and install add-on(export cookies).
Browse to google maps and sign in.
Click add-on and download cookie.
Change name of cookie as described and copy to Hassio config folder.
Restart HA
Voilá

@costas, thanks a lot.

PS: DON´T use Chrome

I’d be interested in knowing the format and the sort of information that is saved in this cookies file you export?

Also, when you get the option to export the cookies is there 2 or 3 different ‘types’ of cookies export options? I know when I have tried through Firefox on my Windows machine I’ve always had multiple options (and have tried them all with no success). The information content of the different export options is clearly different.

Here’s what I’ve had success with in the past: Google device tracker and cookies

Just going to comment as Im having the same issue as the rest here.
If anyone finds a solution please send me a holler.

My setup worked when location sharing made the cookie. You now know how long it has been since I messed with location sharing. I am interested in making another run at presence detections and would like to get location sharing working again. I am on version 0.100.3
This is the most recent thread I could find I may be building my cookie file wrong, but I think my issue is naming the file. No matter what I named the file I get the same error message

The cookie file provided does not provide a valid session. Please create another one and try again.

So my next step was to just delete the file, expecting a file missing and maybe glean the name from doing that. Still, get the same message.

So if I use an example log in of [email protected]. I would expect the name to be

.google_maps_location_sharing.cookies.locatexxxx44_gmail_com

Is that correct?

Once I know that then I can move with confidence that I am doing the file wrong.

Edit
My mistake was adding _gmail_com. My user name was locatexxxx44, but in my configuration, I did not have the @gmail.com.
I copied the google_maps into my custom directory and added the file name to the error log. That was my clue to what went wrong. I am posting this in case someone else runs across the same issue.

I read a lot and had some problems. Here is what I did to make it work in octomber 2019:

  • shared location to new created account
  • installed Export cookies for Firefox
  • login at maps.google.com
  • save cookie with google.com option not www…com
  • renamed .google_maps_location_sharing.cookies.NEWACCOUNTNAME_gmail_com
    (replace NEWACCOUNTNAME with yours)
  • copy file in home assistant dirrectory
  • add in configuration.yaml:
    device_tracker:

wow, working!

1 Like

so I have to remove the “_google” from the cookie-name?

my mistake when edited my account name erased gmail from it, now is ok
correct: .google_maps_location_sharing.cookies.NEWACCOUNTNAME_gmail_com

Ok. I did not pay attention before and used Domain @google.com. after switching to the correct @gmail.com it worked for me.

@seanomat sorry for taking so long to get back. Glad you got it going.
My mistake was how I did the user name in the configuration. Instead of saying [email protected], I just did googlemapsuser. So when I created the file name with the _gmail_com it could not find the file. I did do some testing. I did add the @gmail.com to the user and then my file did work. I then removed the @gmail.com from the user and corrected the file name without the _gmail_com and that worked also. That tells me they have to match but both forms seem correct.

From what I’m reading here, this component still involves manually logging into a browser and copying the access token over to HA? Is there no way this component can retrieve the access token with no intervention from the user like the google calendar component does?

2019-11-04 12:32:44 INFO (SyncWorker_0) [googleapiclient.discovery] URL being requested: GET https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest
2019-11-04 12:32:44 INFO (SyncWorker_0) [googleapiclient.discovery] URL being requested: GET https://www.googleapis.com/calendar/v3/calendars/[My calendar information removed]
2019-11-04 12:32:44 INFO (SyncWorker_0) [oauth2client.transport] Refreshing due to a 401 (attempt 1/2)
2019-11-04 12:32:44 INFO (SyncWorker_0) [oauth2client.client] Refreshing access_token

For some reason no, it´s still not possible. Perhaps @costas can illustrate us.

Cheers

Hi! The google calendar is an official api that provides an access token. The google maps sharing is not a public service and there is no api and of course no api token. What the component does, is it mimicks a browser and polls the api, thus you need to provide valid cookies. Initially the authentication was managed automatically, but google has many different ways to authenticate depending on locale and you can imagine that they are not super happy with people using undocumented, unofficial apis so they are doing everything they can to prevent unauthorized access. So the only viable, easy solution is to log in manually and extract the authenticated cookies. I hope this explanation helps.

I did exactly the same today and it worked instantly.
But I do have a question.
I added an extra device that shares it’s location with the created acount.
Both devices are prefectly tracked in google maps.
But in Home Assistant I still get only 1 set of coordinates.

How do I track multiple devices ???

Got it working now by using th FireFox cookies adn click to export all cookies

I just can’t get this working.

I tried to set up my second account to share location to my primary account.
Did all the things you should, didn’t work.
Tried the other way around and that didn’t work either.

All descriptions say “new account”, so I created a new account and tried to link that to main account but still no luck.
I keep getting the message: The cookie file provided does not provide a valid session. Please create another one and try again.

Then I figured I would try something new. I removed the file and restarted my raspberry.
I still got the same message.
It seems quite obvious now, after about 5 hours of trying, that the message is the same with, without or with a completely different cookie file.

device_tracker:

And the cookie file is downloaded either with chrome or firefox. Have tried them both.
Renamed the files to .google_maps_location_sharing.cookies.Main_Account_com.txt
or .google_maps_location_sharing.cookies.second_gmail_com.txt
or .google_maps_location_sharing.cookies.new_gmail_com.txt
and placed in the config folder.

I’m exhausted with all the tries and I just can’t understand what I’m doing wrong.
I have also read all threads I could find trying to find something that I’m doing wrong.

The only thing I can see that is different is that everyone says maps.google.com, but when I go there I get redirected to Google Maps. But I can’t do anything about that.

@Hellis81 ,
I’m in the same situation. I used to have it set up, but i’ve been redoing my home assistant setup and it’s driving me nuts… Just like you it’s exhausting because it really doesn’t seem to work anymore. If anyone comes up with a solution (or just a confirmation that this integration is broken) then at least i can look at an alternative.