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

Missing essential info, cannot instantiate authenticated person %s: list index out of range #88

Closed indykoning closed 3 years ago

indykoning commented 3 years ago

When i try to call the get_authenticated_person function in a simple script like:

from locationsharinglib import Service
service = Service(<cookies.txt>, <email>);
print(service.get_authenticated_person())

I get None back, after enabling debugging i see it ending with the message Missing essential info, cannot instantiate authenticated person xxx@gmail.com: list index out of range

It has something to do with this line: https://github.com/costastf/locationsharinglib/blob/main/locationsharinglib/locationsharinglib.py#L194 because this is my output

[
    None, 
    None, 
    'XXXXXX', 
    'XXXX', 
    None, 
    None, 
    'XXXXX==', 
    0000, 
    000000000
]

My output does not have a 9th index, is this a common occurence and an easy fix? Or did google change their API and is this a problem?

costastf commented 3 years ago

Hi @indykoning, i have not had a report like this before so i would say that it is not a common occurence. On the other hand, does the response provide any useful info that would might want access to? I mean do any of the XXXXX have info that would be useful? We could fix the code to accept this payload since apparently google is not consistent in their responses across the globe, but I am a bit doubtful about the value of this.

au190 commented 3 years ago

I have the same issue, for few days, Authentication is good from session, but no data in Europe.

costastf commented 3 years ago

@au190 no data for the accounts that are sharing their location, or no data for the account that the locations are being shared? The account that the locations are being shared did not expose that much info anyway so as i said above i am not sure on the value of it. If you don't have any data on the accounts that are sharing their location then we have a different issue and I need to look into it.

au190 commented 3 years ago

For me this config is working more then 2 years. I have accounts to share the data. But form now several days it was stoped working. I thought was problem with the session, I regenerated the session, but still no data form the accounts. If somebody esle experiencing this issue please let me know.

costastf commented 3 years ago

Just tried it out myself, it still works for me fine. Could you please provide some debugging logging being mindful to remove all personal info? Just to clarify a bit, the shared account indeed does not return results, but in my setup it was a dummy account that has nothing to share. The accounts sharing locations are working properly. What is the situation with you guys and can i have some debugging logs to have a look?

On Fri, Apr 16, 2021 at 10:40 AM au190 @.***> wrote:

For me this config is working more then 2 years. I have accounts to share the data. But form now several days it was stoped working. I thought was problem with the session, I regenerated the session, but still no data form the accounts.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/costastf/locationsharinglib/issues/88#issuecomment-821019665, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDMK27DQKQV7VMRAFHIPWTTI7ZYBANCNFSM43ACM6QA .

costastf commented 3 years ago

It seems that the authenticated person is missing from the payload completely. I did not notice, because i am using a dummy account with no useful info to retrieve.

au190 commented 3 years ago

Just tried it out myself, it still works for me fine. Could you please provide some debugging logging being mindful to remove all personal info? Just to clarify a bit, the shared account indeed does not return results, but in my setup it was a dummy account that has nothing to share. The accounts sharing locations are working properly. What is the situation with you guys and can i have some debugging logs to have a look? On Fri, Apr 16, 2021 at 10:40 AM au190 @.***> wrote: For me this config is working more then 2 years. I have accounts to share the data. But form now several days it was stoped working. I thought was problem with the session, I regenerated the session, but still no data form the accounts. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#88 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDMK27DQKQV7VMRAFHIPWTTI7ZYBANCNFSM43ACM6QA .

Can you help me how can I enable the debug mode for this specific librarry ?

au190 commented 3 years ago

I find out on my docker I have HA and python 3.7 and stoped working to get the info, but I have a dev PyCharm same config wehre is wokring properly wiht the same session file, and lib version. The difference is the lib is commpiled with the python 3.6 is working fine wiht PyCharm, but in docker I have python 3.7 there Iam not getting any info. Iam not sure if this is the bug, but as of now I can see this differences between the 2 systems. Iam not aware how to enable the debug for the lib.

device_tracker.cpython-36.pyc device_tracker.cpython-37.pyc

If you have any advice, let me know. Thx.

costastf commented 3 years ago

there is nothing special about this library, it uses standard python logging.

import logging
logging.basicConfig(level=logging.DEBUG)

before you instantiate the library would work just fine.

au190 commented 3 years ago

I have this logs

`DEBUG:root:--> python:[3.7.6] DEBUG:locationsharinglib.Service:Trying to load text based cookies. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myaccount.google.com:443 DEBUG:urllib3.connectionpool:https://myaccount.google.com:443 "GET /?hl=en HTTP/1.1" 302 0 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): accounts.google.com:443

DEBUG:root:--> python:[3.7.6] DEBUG:locationsharinglib.Service:Trying to load text based cookies. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myaccount.google.com:443 DEBUG:urllib3.connectionpool:https://myaccount.google.com:443 "GET /?hl=en HTTP/1.1" 302 0 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): accounts.google.com:443 DEBUG:urllib3.connectionpool:https://accounts.google.com:443 "GET /ServiceLogin?service=accountsettings&passive=1209600&osid=1&continue=https://myaccount.google.com/?hl%3Den&followup=https://myaccount.google.com/?hl%3Den&hl=en&authuser=0 HTTP/1.1" 302 546 DEBUG:urllib3.connectionpool:https://myaccount.google.com:443 "GET /accounts/SetOSID?authuser=0&continue=https%3A%2F%2Fmyaccount.google.com%2F%3Fhl%3Den%26pli%3D1&osidt=ALWU2cvD_sM4Bkd6GLj0MntmgEwiogrf7ZvjDLYa00qM-yZJ75XKqB-jlWjhWSghA1Iv_jo8JcpwBD02FMcslBrFP_MQ8ncRvW6yy38gBknS-tRGQmVl2wGVk5Ulp7734Ga5FQyuqUUgQsv0Cm7eut7I7B9KulBgNdDwx-Seq8S-3qy61MLpkVVhaHwwCDNOUwRpGKekZVOv6h5Y83oNgQg6g HTTP/1.1" 302 0 DEBUG:urllib3.connectionpool:https://myaccount.google.com:443 "GET /?hl=en&pli=1 HTTP/1.1" 200 None DEBUG:locationsharinglib.Service:Getting personal account page and its cookies... b'<!doctype html><meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-wid

........

ass="gb_Hd">Google apps

Main menu
' DEBUG:urllib3.connectionpool:https://myaccount.google.com:443 "GET /?hl=en HTTP/1.1" 200 None DEBUG:locationsharinglib.Service:Validating access to personal account... DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.google.com:443 DEBUG:urllib3.connectionpool:https://www.google.com:443 "GET /maps/preview/locationsharing/read?authuser=0&hl=en&gl=us&pb=%211m7%218m6%211m3%211i14%212i8413%213i5385%212i6%213x4095%212m3%211e0%212sm%213i407105169%213m7%212sen%215e1105%2112m4%211e68%212m2%211sset%212sRoadmap%214e1%215m4%211e4%218m2%211e0%211e1%216m9%211e12%212i2%2126m1%214b1%2130m1%211f1.3953487873077393%2139b1%2144e1%2150e0%2123i4111425 HTTP/1.1" 404 1917 DEBUG:locationsharinglib.Service:<!DOCTYPE html>

Error 404 (Not Found)!!1

404. That’s an error.

The requested URL /maps/preview/locationsharing/read?authuser=0&hl=en&gl=us&pb=%211m7%218m6%211m3%211i14%212i8413%213i5385%212i6%213x4095%212m3%211e0%212sm%213i407105169%213m7%212sen%215e1105%2112m4%211e68%212m2%211sset%212sRoadmap%214e1%215m4%211e4%218m2%211e0%0e0%2123i4111425 was not found on this server. That’s all we know. WARNING:locationsharinglib.Service:Received response code:404 DEBUG:locationsharinglib.Service:[''] DEBUG:locationsharinglib.Service:[''] DEBUG:locationsharinglib.Service:Missing essential info, cannot instantiate authenticated person`

costastf commented 3 years ago

You are using an old version of the library that is using the preview and end point. Apparently the preview end point has been deprecated so it no longer works. Please install the latest version of the library that uses the rpc end point and then things will work properly.

au190 commented 3 years ago

Yes, that was the issue. Even I updated in the manifest file to the new version of locationsharinglib it was not done in the HA python enviroment. So I did it manually. Now its working.

Thank you very much your help.

andrewjohnston99 commented 3 years ago

I started having the same issue today. It will pull the location once, maybe twice, then throw this error in the debug log:

DEBUG:locationsharinglib.Service:Missing essential info, cannot instantiate authenticated person XXXX@gmail.com: list index out of range

Running Python 3.7.3 32 bit and have Version 4.1.6 of the library installed.

andrewjohnston99 commented 3 years ago

I was able to find my specific issue. Apparently the phone that was sharing it's location started overheating and as such either stopped sending out its location at all or just stopped sending all fields. I am using this for a project at school and was working on making a demo so I was screen recording on the phone when it failed. Must have been too much for it to do at once. Works fine without it running!

costastf commented 3 years ago

Great to hear!