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

CookieGetter object has no attribute '_initialize' #50

Closed emilyboda closed 5 years ago

emilyboda commented 5 years ago

I recently noticed the module was not working as it did before, my cookies had expired. I went to run the get-maps-cookies cli tool and it throws the following error.

Traceback (most recent call last):
  File "/usr/local/bin/get-maps-cookies", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/locationsharinglib/cli.py", line 137, in main
    CookieGetter(args.email, args.password, args.cookies_file)
  File "/usr/local/lib/python3.5/dist-packages/locationsharinglib/locationsharinglib.py", line 348, in __init__
    cookies_file=cookies_file)
  File "/usr/local/lib/python3.5/dist-packages/locationsharinglib/locationsharinglib.py", line 215, in __init__
    self._authenticate()
  File "/usr/local/lib/python3.5/dist-packages/locationsharinglib/locationsharinglib.py", line 351, in _authenticate
    initial_form = self._initialize()
AttributeError: 'CookieGetter' object has no attribute '_initialize'

I'm not sure how to solve this issue.

In addition, I seem to remember that a person could theoretically get their cookies from the browser and copy and paste them into the file, is that right? I have attached a screenshot of where I think I could get the cookies, but I'm not sure which value to pick. I blacked out the values of the cookies themselves because I imagine that could be sensitive? Not sure.

Anyway, could I just copy and paste the value of one of these cookies into the contents of my cookies.conf file? Currently when I open my cookies.conf file in nano it looks like a mess of unicode errors. cookies question

costastf commented 5 years ago

Hi emily, i am afraid that google has been changing their authentication and that broke things. Please look at https://github.com/costastf/locationsharinglib/issues/42, especially at https://github.com/costastf/locationsharinglib/issues/42#issuecomment-431348865 for a patch by @lufton to see if it can get you going again. The plan forward is to completely decouple the the library by the cookie getting process. I am planning to work on it the first week of the year if things go as planned with my schedule.

if that does not work you can try out this in case it works for you with some manual effort:

import pickle

COOKIES_FILE='cookies_file_path'

cookies="""
<RequestsCookieJar[\
<Cookie APISID= for .google.com/>, 
<Cookie CONSENT= for .google.com/>, 
<Cookie HSID= for .google.com/>, 
<Cookie NID= for .google.com/>, 
<Cookie SAPISID= for .google.com/>, 
<Cookie SID= for .google.com/>, 
<Cookie SIDCC= for .google.com/>, 
<Cookie SSID= for .google.com/>, 
<Cookie APISID= for .google.com/>, 
<Cookie CONSENT= for .google.com/>, 
<Cookie HSID= for .google.com/>, 
<Cookie NID= for .google.com/>, 
<Cookie SAPISID= for .google.com/>, 
<Cookie SID= for .google.com/>, 
<Cookie SSID= for .google.com/>, 
<Cookie ACCOUNT_CHOOSER= for accounts.google.com/>, 
<Cookie GALX= for accounts.google.com/>, 
<Cookie GAPS= for accounts.google.com/>, 
<Cookie LSID= for accounts.google.com/>, 
<Cookie OSID= for myaccount.google.com/>]>"""

cfile = open(COOKIES_FILE, 'wb')
pickle.dump(''.join(cookies.splitlines()), cfile)

Closing this as this is not going to get fixed in the current form of the code.