Google Maps Location Sharing Error

I’m trying to set up Google Maps Location Sharing and am running into an error:

2018-05-15 07:20:40 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 36, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 54, in __init__
    hass.config.path(CREDENTIALS_FILE))
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 332, in __init__
    cookies_file=cookies_file)
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 188, in __init__
    if cookies_file and self._validate_cookie(cookies_file):
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 215, in _validate_cookie
    raise InvalidCookies(message)
locationsharinglib.locationsharinglibexceptions.InvalidCookies: The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again

I’ve confirmed that I can log into the newly created account and see the location of my phone from that account. I have confirmed that I am using the correct username and password. I received an email the first time I logged into the account using HASS saying that it might be suspicious activity. I confirmed that it was me and rebooted. The problem remains. I’m using version 0.69 under HASSbian.

Any help in troubleshooting this would be greatly appreciated.

Looks like it has to do with invalid cached data somewhere. Maybe on your phone?

Hmm… I don’t know. I did see that I do have a file called ‘.google_maps_location_sharing.cookies’ in my homeassistant directory now but I do not have the file ‘google_maps_location_sharing.conf’ that should be created as mentioned in the docs.

well thats because you haven’t connected for it to create the config. Either way your error is related to validating the cookies. Not sure where those cookies are stored or how/when they are created.

So perhaps the cookies issue is local and not the phone if it hasn’t connected. I tried removing the cookies file I mentioned above and restarting but I’m seeing the same error.

Digging further, I changed my password in the configuration.yaml file and got the same error:

2018-05-16 08:16:43 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 36, in setup_scanner
    scanner = GoogleMapsScanner(hass, config, see)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/google_maps.py", line 54, in __init__
    hass.config.path(CREDENTIALS_FILE))
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 332, in __init__
    cookies_file=cookies_file)
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 188, in __init__
    if cookies_file and self._validate_cookie(cookies_file):
  File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 215, in _validate_cookie
    raise InvalidCookies(message)
locationsharinglib.locationsharinglibexceptions.InvalidCookies: The cookies provided do not provide a valid session.Please authenticate normally and save a valid session again

Before changing my password in the config file, I copy/pasted my username and password into gmail.com and I was able to log in. I did this to ensure I didn’t have a typo in either.

I can’t understand how this is happening as the configuration is very straightforward. I’ve followed all steps outlined and it will not authenticate.

Other people have had issues if the device they are sharing the location from has more than one google profile. Maybe thats it?

https://github.com/home-assistant/home-assistant/pull/14359

1 Like

I’ve figured it out. Google was blocking the log in for the new user. I set this up at work and my work IP is in a city that’s about 500 miles from my home. Everything is routed from the headquarters. When HASS was trying to use that ID, Google was blocking the log in. I remoted into my home machine and logged in there it then allowed HASS to log in.

Sorry for the trouble.