costastf / locationsharinglib

A library to retrieve coordinates from an google account that has been shared locations of other accounts.
MIT License
170 stars 29 forks source link

Error on simple usage test #115

Closed MarkLuk closed 10 months ago

MarkLuk commented 10 months ago

Test:

from locationsharinglib import Service

cookies_file = 'xxxxx'
google_email = 'xxxxx@gmail.com'

service = Service(cookies_file=cookies_file, authenticating_account=google_email)

for person in service.get_all_people():
    print(person)

Cookies file:

.google.com TRUE    /   TRUE    0000000000  1P_JAR  2023-12-29-10
.google.com TRUE    /   TRUE    0000000000  AEC XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.google.com TRUE    /   TRUE    0000000000  NID 511=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Error:

Traceback (most recent call last):
  File "c:\Users\XXXX\Downloads\test.py", line 6, in <module>
    service = Service(cookies_file=cookies_file, authenticating_account=google_email)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\XXXXX\Python311\Lib\site-packages\locationsharinglib\locationsharinglib.py", line 98, in __init__
    self._session = self._validate_cookie(cookies_file or '')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\XXXXX\Python311\Lib\site-packages\locationsharinglib\locationsharinglib.py", line 153, in _validate_cookie
    session = self._get_authenticated_session(cookies_file)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\XXXXX\Python311\Lib\site-packages\locationsharinglib\locationsharinglib.py", line 146, in _get_authenticated_session
    session = self._get_session_from_cookie_file(cfile.read())
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\XXXXX\Python311\Lib\site-packages\locationsharinglib\locationsharinglib.py", line 132, in _get_session_from_cookie_file
    domain, flag, path, secure, expiry, name, value, *rest = entry.split()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected at least 7, got 6)
MarkLuk commented 10 months ago

Environment versions

Requirement already satisfied: locationsharinglib in python311\lib\site-packages (5.0.2)
Requirement already satisfied: coloredlogs>=15.0.1 in python311\lib\site-packages (from locationsharinglib) (15.0.1)
Requirement already satisfied: requests>=2.31.0 in python311\lib\site-packages (from locationsharinglib) (2.31.0)
Requirement already satisfied: cachetools>=5.3.1 in python311\lib\site-packages (from locationsharinglib) (5.3.2)
Requirement already satisfied: pytz>=2023.3 in python311\lib\site-packages (from locationsharinglib) (2023.3)
Requirement already satisfied: humanfriendly>=9.1 in python311\lib\site-packages (from coloredlogs>=15.0.1->locationsharinglib) (10.0)
Requirement already satisfied: charset-normalizer<4,>=2 in python311\lib\site-packages (from requests>=2.31.0->locationsharinglib) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in python311\lib\site-packages (from requests>=2.31.0->locationsharinglib) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in python311\lib\site-packages (from requests>=2.31.0->locationsharinglib) (2.0.2)
Requirement already satisfied: certifi>=2017.4.17 in python311\lib\site-packages (from requests>=2.31.0->locationsharinglib) (2023.5.7)
Requirement already satisfied: pyreadline3 in python311\lib\site-packages (from humanfriendly>=9.1->coloredlogs>=15.0.1->locationsharinglib) (3.4.1)
costastf commented 10 months ago

The cookies are wrong. How did you aquire them?

MarkLuk commented 10 months ago

Firefox -> "Export Cookies" extension

On Fri, Dec 29, 2023 at 3:54 PM Costas @.***> wrote:

The cookies are wrong. How did you aquire them?

— Reply to this email directly, view it on GitHub https://github.com/costastf/locationsharinglib/issues/115#issuecomment-1872107612, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGL2BEU5Z3CF3EXQOOH37LYL3DSPAVCNFSM6AAAAABBGVEZDKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZSGEYDONRRGI . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Mark.

MarkLuk commented 10 months ago

Update: I've exported cookies files from Chrome->Get cookies.txt LOCALLY extension, now it works fine. Maybe it is best to add a warning about Firefox-> "Export Cookies" extension in the README Closing the issue.

costastf commented 10 months ago

Hi, thanks for posting, there have been a few discussions on closed issues and over at home assistant forums about this. Sadly I cannot keep track of all the cookie export addons so millage might vary. Happy you got your issue fixed, enjoy the holidays!