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

Unable to get any data. #68

Closed phrfpeixoto closed 5 years ago

phrfpeixoto commented 5 years ago

Hello,

I just followed your simple example and I'm getting no data from it at all. My cookie seems correct and I generated it using this: https://mapscookiegettercli.readthedocs.io/en/latest/

import sys
import logging
from locationsharinglib import Service

root = logging.getLogger()
root.setLevel(logging.DEBUG)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)

cookies_file = 'cookie'
google_email = 'ha.phrfpeixoto@gmail.com'
service = Service(cookies_file=cookies_file, authenticating_account=google_email)
pp = service.get_all_people()
for person in pp:
    print(person)

I'm attaching my output here. Could you please provide any help debugging this?

out.txt

costastf commented 5 years ago

From what I can see you are authenticated but there is no info shared. Have you actually enabled location sharing towards the account you created the cookie for from some other account?

phrfpeixoto commented 5 years ago

Hi! Thanks for replying.

Yes, it's enabled! I have it set up on my phone and I can see the shared locations directly on Google Maps.

costastf commented 5 years ago
2019-08-23 14:31:39,282 - locationsharinglib.Service - DEBUG - [None, None, '0ahUKEwj9iZfuwpnkAhVJI7kGHTioCeUQ8ZABCAE', '-yJgXb2gDcnG5OUPuNCmqA4', None, None, 'GgA=', 1800, 1566581499228]
2019-08-23 14:31:39,282 - locationsharinglib.Service - DEBUG - [None, None, '0ahUKEwj9iZfuwpnkAhVJI7kGHTioCeUQ8ZABCAE', '-yJgXb2gDcnG5OUPuNCmqA4', None, None, 'GgA=', 1800, 1566581499228]
2019-08-23 14:31:39,282 - locationsharinglib.Service - DEBUG - Missing essential info, cannot instantiate authenticated person

These lines log the response the library received from the service for the shared accounts. Although the format is what is expected the data as you can tell is incomplete and that is why the library chokes and says there are essential info missing. Not sure how I can help here, since the authentication seems to have worked and the service responds with the expected data for the user, only with no actual info for them.

phrfpeixoto commented 5 years ago

Could this be country related?

costastf commented 5 years ago

I can't really think why that would be the case. I can't come up with an idea about why this should be happening, except that the authentication is not proper and that is why you get incomplete responses. It is confusing...

On Mon, Aug 26, 2019 at 10:10 PM phrfpeixoto notifications@github.com wrote:

Could this be country related?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/costastf/locationsharinglib/issues/68?email_source=notifications&email_token=ABDMK25KMCBIHHTOJCRMDYLQGQ2E3A5CNFSM4IPBZ5F2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5FQ4EY#issuecomment-525012499, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDMK2ZWV7LDJZEAUXHUSGLQGQ2E3ANCNFSM4IPBZ5FQ .

phrfpeixoto commented 5 years ago

Thanks for sticking to this.

Is there any information on what these random strings are or how can I decode these?

Or where to find debugging information on theses responses?

Are you able to run the code successfully using another account?

If I provide you the cookie, are you able to validate it?

costastf commented 5 years ago

Please don't provide the cookie as that is your personal google account authenticated and you wouldn't want to share this around. If you look at the code, you can identify the payload expected. I will try to think of something during this week to try to help.

costastf commented 5 years ago

I am almost certain that the problem is with your authentication. I am currently working on implementing text based cookies that can be exported from an addon as per #66 and I have the same response as you although when I use a properly authenticated cookie everything works. So the problem is probably that the authentication is not done, but the identification of the wrong authentication is not kicking in correctly. That of course can be location based. Long story short, please be a bit patient while I implement the text based cookie and see how that works.

phrfpeixoto commented 5 years ago

Sure. Thanks for helping. Is the cookie supposed to be obtained from mapscookiegettercli?

costastf commented 5 years ago

Yeah, but that's reported blocked by google so no more of that :)

phrfpeixoto commented 5 years ago

Is there another way of getting such cookie?

costastf commented 5 years ago

Currently no, but you can install the cookies.txt add-on in chrome and give the latest branch I have uploaded a try and see if that works for you for now. It's a work in progress.

costastf commented 5 years ago

https://github.com/costastf/locationsharinglib/tree/text-based-cookies has been tested with firefox with this addon https://github.com/rotemdan/ExportCookies (Prefix HttpOnly cookies has to be unchecked) and with chrome with this addon https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg and they both work fine. If you want to give that a spin and report back any possible issues that would be great!

phrfpeixoto commented 5 years ago

Will do that.

phrfpeixoto commented 5 years ago

It worked! I can see the data from the shared ppl logged on to the terminal. Nice to see it's progressing. When do you expect to release this? If help is needed, I can try to help.

Your requirements file is missing dataclasses and pytz

phrfpeixoto commented 5 years ago

I guess we should also try and determine which of these cookies are indeed required for the location sharing authentication and service. There are the cookies I obtained on a clean browser, going directly to maps.google.com and logging in (cookie values are omitted):

.google.com TRUE    /   FALSE   1630263368  SID
.google.com TRUE    /   FALSE   1630263368  HSID
.google.com TRUE    /   TRUE    1630263368  SSID
.google.com TRUE    /   FALSE   1630263368  APISID
.google.com TRUE    /   TRUE    1630263368  SAPISID
accounts.google.com FALSE   /   TRUE    1630263368  ACCOUNT_CHOOSER
.google.com TRUE    /   FALSE   2146723199  CONSENT
.google.com TRUE    /   FALSE   1582743369  SEARCH_SAMESITE
.google.com TRUE    /   FALSE   1569783372  1P_JAR
.google.com TRUE    /   FALSE   1583002572  NID
accounts.google.com FALSE   /   TRUE    1630263373  GAPS
accounts.google.com FALSE   /   TRUE    1630263373  LSID
.google.com TRUE    /   FALSE   1574967377  SIDCC
costastf commented 5 years ago

I think that I will wait for @macf0x to have a try at it and then I will release. I have tested it to my satisfaction so I am not really worried but it is always good to have a few more pair of eyes. Through the weekend I think.

costastf commented 5 years ago

Why do you think it is worth figuring out which are actually needed? I think that actually filtering cookies will make things more fragile.

phrfpeixoto commented 5 years ago

Indeed it makes sense. Okay, I just thought about storing the least possible information on a plain text file.

costastf commented 5 years ago

Hopefully that will come out of the addon so people should not even bother with it. Indeed i am missing pytz, fixing right now, thanks for that. dataclasses are in 3.7 but now that you mentioned it, i probably need to refactor the code to work without them because home assistant does not yet run on 3.7. So that's a small thing to do before releasing...

costastf commented 5 years ago

Dependencies fixed, thanks for the heads up. I stuck with dataclasses and added the marker for 3.6 as I think that the latest home assistant is running on 3.6 so its fine to use them.

phrfpeixoto commented 5 years ago

Sure. Home to see this new version on homeassistant soon. Are you maintaining the code on the HA component as well?

costastf commented 5 years ago

No, someone was kind enough to take that over, i am a bit spread thin already as it is...

tyjtyj commented 5 years ago

@costastf , I was using 3.09 and great till going to 4.0.2 this issue started

the cookie file definately working fine... any way find out what is no parsing correctly ?

tyjtyj commented 5 years ago

I removed line 172 email used for authentication and it works for now .

172 people = self.get_shared_people() #+ [self.get_authenticated_person()]

costastf commented 5 years ago

I am sorry but I don't understand what the issue is @tyjtyj

tyjtyj commented 5 years ago

I am getting error Missing essential info, cannot instantiate authenticated person

Seems the cookies file does not contains data for gmail owner Thus, i removed below from line 172 people = self.get_shared_people() + [self.get_authenticated_person()]

replace with people = self.get_shared_people()

It works for now

costastf commented 5 years ago

That is not an error, that is a warning. There are people that use their own accounts to track shares of other accounts and they want to see their own info. That is what that does. If you are using another account that is not sharing it's own location there is nothing to show and thus the message. Having the message does not interfere with the usage at all.

tyjtyj commented 5 years ago

It turn out my issue is not an issue. it is home assistant component broken. Thanks for your time. Sorry @phrfpeixoto i mess up your thread.

costastf commented 5 years ago

version 4.1.0 fixes the issue as it can accept text based cookies from browser addons.

phrfpeixoto commented 5 years ago

I don't see a 4.1.0 tag. Did you mean 4.0.1?

costastf commented 5 years ago

The tag kinda failed on github. It is uploaded on pypi though so just pip install and you are golden.

Kind regards Costas

On Tue, Sep 3, 2019, 16:12 phrfpeixoto notifications@github.com wrote:

I don't see a 4.1.0 tag. Did you mean 4.0.1?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/costastf/locationsharinglib/issues/68?email_source=notifications&email_token=ABDMK2YRT7UPO2SMRLQCIWLQHZWGPA5CNFSM4IPBZ5F2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5YKQ2Y#issuecomment-527476843, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDMK23HEFSMNGFREMGEIJ3QHZWGPANCNFSM4IPBZ5FQ .