@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
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.
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.
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.
Today I update my home assistant, received “The cookie file provided does not provide a valid session. Please create another one and try again.”
I struggle to figure out, but working again.
mistakes:
when renaming the coockie file, BE AWARE of windows selecting only the name, not extension. Delete .txt extension from the filename!
GOOD:
.google_maps_location_sharing.cookies.NEWACCOUNTNAME_gmail_com
NOT GOOD:
.google_maps_location_sharing.cookies.NEWACCOUNTNAME_gmail_com.txt
easy to miss
not sure if was a problem, I logout from firefox first time, second time I just close the firefox and was ok
Spent hours (probably close to 10 hours) trying to get this to work. Followed the various suggestions provided by @Luu and other helpful members, but I’m still getting the ERROR :
[homeassistant.components.google_maps.device_tracker] The cookie file provided does not provide a valid session. Please create a new one and try again.
Per the Home Assistant definition, I use Home Assistant Supervised :
“If you installed Linux and then ran a script to install HA and have add-ons then you have #homeassistant_supervised”
I run a Windows 10 box, with a Linux Mint VM. Home Assistant Supervised is installed in the Linux environment.
I tried using Chrome and Firefox in both Windows 10 and Linux to create the cookie file.
My configuration.yaml and home-assistant.log file reside in the following path which I presume to be the configuration folder :
*\Home\User\docker\hassio\homeassistant*
The aforementioned path is where I save the renamed cookie file : .google_maps_location_sharing.cookies.newuser_gmail_com
it should not be an issue with *.txt extension, as the file becomes hidden/invisible when copied to the configuration directory.
I used the following in my configuration.yaml file :
device_tracker:
-platform: google_maps
username: newuser
Can anyone confirm whether they get the same error message, if they simply delete the cookie file, but keep the device_tracker in the configuration file.
Any other suggestions on how to troubleshoot this item would be greatly appreciated.
I don’t use this platform but if you have the .txt on a filename and whatever interfaces with it is not looking for text files, you will have problems. Even if it’s hidden, the file in question will be filtered by the wildcards provided by the software.
@petro thanks for your response. I was conscious of deleting the *.txt extension when renaming. I also do not see the *.txt extension on the file in Linux so it should be good I think. That said - i’m not sure if HA is even seeing the file to begin with, since I get the same error message when I delete the cookie file.
This is what my cookie looks like - I’m wondering if there should be a reference to maps.google.com anywhere.
I also had lots of problem and spent probably more time than you have. (same error message)
I finally got it working and it was the .txt that was there. That perhaps not your issue but perhaps encoding?
Try and create a new file in Configuator and copy paste the cookie details in it.
But at the end. I’m not sure it was worth it.
The GPS positioning is slow and inaccurate.
When I’m home it often shows about 400-700 m wrong but the HA companion app is within 10 m.
@Hellis81 thanks for your confirmation. Can you clarify what Configurator and where to find it. I’ll give your suggestion a try. My HA Companion app lags terribly unfortunately - which is why I’m looking to try this - since it is running in the background on the phone. The HA app is very slow - it will be running and refreshed on an LTE connection, yet it will still report in Home Assistant that the device is running on Wifi. The tracking is equally bad.
Edit : found it - turned out to be called File Editor in my Supervisor setup. Pasted the contents from that cookie, and named it
Your cookie is ok. Wondering if the location of the file is correct, must be on same location as configuration.yaml file. My file is inside homeassistant\config folder