jeffreydwalter / arlo

Python module for interacting with Netgear's Arlo camera system.
Apache License 2.0
520 stars 123 forks source link

Cannot access shared device #159

Closed DannyYCCheng closed 3 years ago

DannyYCCheng commented 4 years ago

Hi,

I have a feeling this issue is because I am trying to access a shared camera, but thought I'd ask to confirm.

What version of Python are you using (python -V)?

Python 3.8.5

What operating system and processor architecture are you using (python -c 'import platform; print(platform.uname());')?

('Linux', 'tern', '5.4.0-52-generic', '#57-Ubuntu SMP Thu Oct 15 10:57:00 UTC 2020', 'x86_64', 'x86_64')

Which Python packages do you have installed (run the pip freeze or pip3 freeze command and paste output)?

arlo==1.2.38
certifi==2020.11.8
chardet==3.0.4
click==7.1.2
idna==2.10
monotonic==1.5
pycryptodome==3.9.9
PySocks==1.7.1
requests==2.24.0
six==1.15.0
sseclient==0.0.22
urllib3==1.25.11

Which version of ffmpeg are you using (ffmpeg -version)?

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100

Which Arlo hardware do you have (camera types - [Arlo, Pro, Q, etc.], basestation model, etc.)?

Arlo Pro 2, shared device (no access to the base station if one exists)

What did you do?

If possible, provide the steps you took to reproduce the issue. A complete runnable program is good. (don't include your user/password or any sensitive info) Example taken from Taking Fullscreen Snapshots

from arlo import Arlo

USERNAME = 'user@example.com'
PASSWORD = 'supersecretpassword'

try:
    # Instantiating the Arlo object automatically calls Login(), which returns an oAuth token that gets cached.
    # Subsequent successful calls to login will update the oAuth token.
    arlo = Arlo(USERNAME, PASSWORD)
    # At this point you're logged into Arlo.

    # Get the list of devices and filter on device type to only get the basestation.
    # This will return an array which includes all of the basestation's associated metadata.
    basestations = arlo.GetDevices('basestation')

    # Get the list of devices and filter on device type to only get the camera.
    # This will return an array which includes all of the camera's associated metadata.
    cameras = arlo.GetDevices('camera')

    # Tells the Arlo basestation to trigger a snapshot on the given camera.
    # This snapshot is not instantaneous, so this method waits for the response and returns the url
    # for the snapshot, which is stored on the Amazon AWS servers. 
    #snapshot_url = arlo.TriggerFullFrameSnapshot(basestations[0], cameras[0])
    snapshot_url = arlo.TriggerFullFrameSnapshot(cameras[0], cameras[0])

    # This method requests the snapshot for the given url and writes the image data to the location specified.
    # In this case, to the current directory as a file named "snapshot.jpg"
    # Note: Snapshots are in .jpg format.
    arlo.DownloadSnapshot(snapshot_url, 'snapshot.jpg')

except Exception as e:
    print(e)

What did you expect to see?

A snapshot.jpg in the directory.

What did you see instead?

The program hangs and does nothing.

For reference:

basestations = arlo.GetDevices('basestation')
cameras = arlo.GetDevices('camera')

Returns: basestations = [] cameras containing the one camera that was shared with me.

Does this issue reproduce with the latest release?

Yes

jeffreydwalter commented 4 years ago

Can you try the previous release and let me know whether it works for you or not?

jeffreydwalter commented 4 years ago

Oh, just reread what you wrote... These cameras don't work without a base station. Are you saying someone gave you a camera but not a base station? If so, the camera is useless.

DannyYCCheng commented 4 years ago

The device is 'shared' with us from our builder - it is a camera they have installed for our new house build. So they own the admin access to the camera, and we can view it. We don't physically have the camera.

I can access the camera via the Arlo app or from the browser, but I don't have access to the base station, not based on what I can see from the app or when I do arlo.GetDevices('basestation'). I do think it is probably outside of what your code was intended for, but thought I'd check before I give up :)

Update: looking at the app, it says the device is connected to '5TN29B***' (13 letter/digit value). Would this be the base station? If so can I manually enter this information in the code?

jeffreydwalter commented 4 years ago

Can you please run this little helper script and paste the results here?

DannyYCCheng commented 4 years ago
[                                                           
    {                                                       
        "arloMobilePlan": false,                            
        "cvrEnabled": false,                                
        "dateCreated": 1603743296074,                       
        "deviceId": "XXXXXXXXXXXXX",                        
        "deviceName": "",                                   
        "deviceType": "camera",                             
        "displayOrder": 1,                                  
        "firmwareVersion": "1.125.15.0_35_1191",            
        "interfaceSchemaVer": "1",                          
        "interfaceVersion": "i006",                         
        "lastImageUploaded": "true",                        
        "lastModified": 1605055816335,                      
        "mediaObjectCount": 0,                              
        "modelId": "VMC4030P",                              
        "owner": {                                          
            "firstName": "",                                
            "lastName": "",                                 
            "ownerId": "XXXXXX-XXX-XXXXXXXX"                
        },                                                  
        "parentId": "XXXXXXXXXXXXX",                        
        "presignedFullFrameSnapshotUrl": "",                
        "presignedLastImageUrl": "",                        
        "presignedSnapshotUrl": "",                         
        "properties": {                                     
            "hwVersion": "H6",                              
            "modelId": "VMC4030P",                          
            "olsonTimeZone": "Pacific/Auckland"             
        },                                                  
        "state": "provisioned",                             
        "uniqueId": "XXXXXX-XXX-XXXXXXXX_XXXXXXXXXXXXX",    
        "userId": "XXXXX-XXX-XXXXXXXX",                     
        "userRole": "USER",                                 
        "xCloudId": "XXXXXXXX-XXXX-XXX-XXXXXXXXX"           
    }                                                       
]                                                           
DannyYCCheng commented 4 years ago

How did you get on with the results? Please let me know if you require further information from my end :)

jeffreydwalter commented 4 years ago

@DannyYCCheng can you try with the previous version of the library. Also, are the deviceid and parentid the same?

DannyYCCheng commented 4 years ago

The latest previous version is arlo==1.2.35, that didn't work...

No the deviceid and parentid are different.

FYI happy to park this in the too hard basket because i don't have access to the basestation info :)

jeffreydwalter commented 4 years ago

If the arlo website can read that camera, you should be able to as well using this library.

The only way to figure it out would be to open the arlo web app and use the developer tools to watch the network traffic to figure out what http requests it's making to connect to that camera.

My Arlo basestation died about a year ago and I haven't been able to bring myself to fork over the money to buy another Arlo product... :)

jeffreydwalter commented 4 years ago

I'd be happy to jump on a screen share with you to take a look if you want.

DannyYCCheng commented 4 years ago

The only way to figure it out would be to open the arlo web app and use the developer tools to watch the network traffic to figure out what http requests it's making to connect to that camera.

Yep I was thinking of doing that... do you have an example of what that HTTP request looks like? I'll take a look when I have a minute

DannyYCCheng commented 4 years ago

I'd be happy to jump on a screen share with you to take a look if you want.

Thanks for the offer, keen to give this a crack myself, will let you know if I need help

jeffreydwalter commented 4 years ago

image

Before you log in to the Arlo web app, right-click anywhere on the Arlo web app webpage and select "Inspect". That will open the browser's developer tools. From there, click on the "Network" tab, check the "Preserve log" checkbox, and then login.

Once you're logged in, you should see a bunch of HTTP requests.

Arlo using something called "server-sent events" a.k.a. "EventStream": https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

The Arlo API works by "subscribing" to the EventStream by making an HTTP request to the `/notify' API endpoint. The server keeps this request open indefinitely. It is the channel the server uses to push information to the browser. The browser interacts with the server by making HTTP requests, and receiving responses via the EventStream. This allows for asynchronous messaging.

The way I go about deciphering the API is to invoke the action I care about via the web app and watch the HTTP requests being made.

If you want to, click on the button to start the video stream for the shared camera and past all of the network traffic here and I'll see if I can make sense of it.

DannyYCCheng commented 4 years ago

I suspect you are mainly interested in the post/get? These are in chronological order, I've copied what I can see as the unique post/gets.

POST: https://myapi.arlo.com/hmsweb/users/devices/startStream?eventId=FE!ad271b44-e289-4917-98b2-4310b61d523a&time=1605560686705
GET: https://arlostreaming30-z3-prod.wowza.arlo.com:80/stream/A2S10270A10F3_1605560626323.mpd?egressToken=7bbe77d8_f8ad_4d31_8afa_52e0e0fc6ff7&userAgent=web&cameraId=A2S10270A10F3_1605560626323&txnId=FE!ad271b44-e289-4917-98b2-4310b61d523a&watchalong=true
GET: https://arlostreaming30-z3-prod.wowza.arlo.com:80/stream/chunk-A2S10270A10F3_1605560626323-0-00029.m4s
GET: https://arlostreaming30-z3-prod.wowza.arlo.com:80/stream/chunk-A2S10270A10F3_1605560626323-0-00030.m4s
POST: https://myapi.arlo.com/hmsweb/users/devices/notify/5TN29B7EA1316?eventId=FE!558d6228-853b-4567-b2bc-2b8976588052&time=1605560694619

I could also export the whole log as HAR although I suspect that might be excessive, please let me know if you prefer that instead.

jeffreydwalter commented 4 years ago

Take a look around a the requests prior to those. Look for requests made to get device info. I know a year ago it was /devices.

DannyYCCheng commented 4 years ago

I believe the first is the camera and the second is the basestation (which I do not have direct access to)

https://myapi.arlo.com/hmsweb/users/devices/notify/A2S10270A10F3?eventId=FE!5096b7b4-1309-4e9e-bfec-971238a300af&time=1605561700162 https://myapi.arlo.com/hmsweb/users/devices/notify/5TN29B7EA1316?eventId=FE!693f71b5-764f-4357-abb1-248b9f48c372&time=1605561704738

jeffreydwalter commented 4 years ago

You need to get the response from the HTTP request to /devices (or something like that). What you just pasted is /devices/notify.

jeffreydwalter commented 4 years ago

I led you astray... What we need are the requests that happen immediately after you login. Also the ones that happen when you click on the tab to view your shared camera. You are looking for the list of devices (basestations, cameras, etc).

jeffreydwalter commented 4 years ago

This is the request:

      {
        "pageref": "page_1",
        "startedDateTime": "2020-11-17T10:53:37.177+13:00",
        "request": {
          "bodySize": 0,
          "method": "GET",
          "url": "https://myapi.arlo.com/hmsweb/v2/users/devices?t=1605563616541&eventId=FE!05a16e9e-78ee-48d1-b15e-c2e7f6b02e08&time=1605563616542",

            "text": "{\"data\":[{\"userId\":\"\",\"deviceId\":\"A2S10270A10F3\",\"parentId\":\"5TN29B7EA1316\",\"uniqueId\":\"YURAZP-259-51500182_A2S10270A10F3\",\"deviceType\":\"camera\",\"deviceName\":\"Bramley\",\"lastModified\":1605563616830,\"firmwareVersion\":\"1.125.15.0_35_1191\",\"xCloudId\":\"\",\"lastImageUploaded\":\"true\",\"userRole\":\"USER\",\"displayOrder\":1,\"presignedLastImageUrl\":\"https://arlolastimage-z3.s3.amazonaws.com/7a2433f9bbb64fbc80cae93fb9aa1de2/YURAZP-259-51500182/A2S10270A10F3/lastImage.jpg?AWSAccessKeyId=&Expires=1605650016&Signature=e3U69rQEC0EPuFq9uTQOUQHnR7c%3D\",\"presignedSnapshotUrl\":\"https://arlos3-prod-z3.s3.amazonaws.com/7a2433f9bbb64fbc80cae93fb9aa1de2/YURAZP-259-51500182/A2S10270A10F3/snapshot.jpg?AWSAccessKeyId=AKIA2BAHQO5QZGD7VOMI&Expires=1605650016&Signature=U2uGOKXP6ZA%2FkR7aghjo2qqeh4A%3D\",\"presignedFullFrameSnapshotUrl\":\"https://arlos3-prod-z3.s3.amazonaws.com/7a2433f9bbb64fbc80cae93fb9aa1de2/YURAZP-259-51500182/A2S10270A10F3/fullFrameSnapshot.jpg?AWSAccessKeyId=&Expires=1605650016&Signature=3pyC37eCYdfIg3B%2BFIwgEy90FoA%3D\",\"mediaObjectCount\":0,\"state\":\"provisioned\",\"modelId\":\"VMC4030P\",\"cvrEnabled\":false,\"dateCreated\":1603743296074,\"arloMobilePlan\":false,\"interfaceVersion\":\"i006\",\"interfaceSchemaVer\":\"1\",\"owner\":{\"firstName\":\"japan\",\"lastName\":\"homes\",\"ownerId\":\"YURAZP-259-51500182\"},\"properties\":{\"modelId\":\"VMC4030P\",\"olsonTimeZone\":\"Pacific/Auckland\",\"hwVersion\":\"H6\"}}],\"success\":true}"
          },

I deleted those files you uploaded because they contain sensitive info. Take a look at the text section above. It appears that your camera is the only device you get back.

It looks like they are subscribing to the basestation based on the parentID in the above response:

      {
        "pageref": "page_1",
        "startedDateTime": "2020-11-17T10:53:37.977+13:00",
        "request": {
          "bodySize": 232,
          "method": "POST",
          "url": "https://myapi.arlo.com/hmsweb/users/devices/notify/5TN29B7EA1316?eventId=FE!056a575f-799c-4955-8b3c-833dace07553&time=1605563617565",

            "text": "{\"from\":\"RPJNZ-259-54183589_web\",\"to\":\"5TN29B7EA1316\",\"action\":\"set\",\"resource\":\"subscriptions/RPJNZ-259-54183589_web\",\"publishResponse\":false,\"transId\":\"web!624b0ec4.39d138!1605563617564\",\"properties\":{\"devices\":[\"A2S10270A10F3\"]}}"

I can probably figure out a way to make all this work, but will need a little time to think about it... Basically, we just need to post to /notify with the above JSON to subscribe to the evenstream.

DannyYCCheng commented 4 years ago

Thanks for deleting the files; I only did a quick search for email/password, wasn't sure whether there were other sensitive information.

Thanks for the update, look forward to what you can come up with :)

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.