JurajNyiri / pytapo

Python library for communication with Tapo Cameras
MIT License
277 stars 58 forks source link

Exception: Invalid authentication data #80

Closed NicoCaldo closed 10 months ago

NicoCaldo commented 10 months ago

I've 2 C210 correctly linked to a single account and to the WiFi network.

One of them, suddenly, because I've wrongly left the auto update option ON, automatically updated its firmware

Now, for some reason, even if I'm using admin as a user, I've having the issue

File "/home/lab/dashboardlab/.venv/lib/python3.10/site-packages/pytapo/__init__.py", line 269, in refreshStok
    raise Exception("Invalid authentication data")
Exception: Invalid authentication data

The C210 that still works

The C210 that has the Invalid authentication data issue

pytapo is updated to the latest version. IP is correct as I'm able to see it via rstp

NicoCaldo commented 10 months ago

It seems it was introduced here https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues/436

JurajNyiri commented 10 months ago

Factory reset camera / readd to tapo app, there is a bug in camera for some users where it does not properly load the new password hash. And use the latest version of pytapo.

robozb commented 10 months ago

On my C110 (FW: 1.3.9) the solution was: simple upgrade to the latest pytapo (in the virt env):

Before:

Traceback (most recent call last):
  File "/home/pytapo/pytapo/tapo-camera-on.py", line 10, in <module>
    tapo1 = Tapo(host1, user, password)
  File "/home/pytapo/pytapo/virt/lib/python3.9/site-packages/pytapo/__init__.py", line 45, in __init__
    self.basicInfo = self.getBasicInfo()
  File "/home/pytapo/pytapo/virt/lib/python3.9/site-packages/pytapo/__init__.py", line 364, in getBasicInfo
    return self.executeFunction(
  File "/home/pytapo/pytapo/virt/lib/python3.9/site-packages/pytapo/__init__.py", line 105, in executeFunction
    data = self.performRequest(
  File "/home/pytapo/pytapo/virt/lib/python3.9/site-packages/pytapo/__init__.py", line 128, in performRequest
    self.ensureAuthenticated()
  File "/home/pytapo/pytapo/virt/lib/python3.9/site-packages/pytapo/__init__.py", line 65, in ensureAuthenticated
    return self.refreshStok()
  File "/home/pytapo/pytapo/virt/lib/python3.9/site-packages/pytapo/__init__.py", line 84, in refreshStok
    raise Exception("Invalid authentication data")
Exception: Invalid authentication data
10:12:14 Normal: --- Startup, daemonizing ---

Upgrade:

source virt/bin/activate
(virt) root@rpi4:/home/pytapo/pytapo# python3 -m pip install pytapo --upgrade
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pytapo in ./virt/lib/python3.9/site-packages (2.8)
Collecting pytapo
  Downloading https://www.piwheels.org/simple/pytapo/pytapo-3.3.6-py3-none-any.whl (29 kB)
Requirement already satisfied: pycryptodome in ./virt/lib/python3.9/site-packages (from pytapo) (3.16.0)
Requirement already satisfied: requests in ./virt/lib/python3.9/site-packages (from pytapo) (2.28.1)
Requirement already satisfied: urllib3 in ./virt/lib/python3.9/site-packages (from pytapo) (1.26.13)
Collecting rtp
  Downloading https://www.piwheels.org/simple/rtp/rtp-0.0.3-py3-none-any.whl (14 kB)
Requirement already satisfied: certifi>=2017.4.17 in ./virt/lib/python3.9/site-packages (from requests->pytapo) (2022.12.7)
Requirement already satisfied: idna<4,>=2.5 in ./virt/lib/python3.9/site-packages (from requests->pytapo) (3.4)
Requirement already satisfied: charset-normalizer<3,>=2 in ./virt/lib/python3.9/site-packages (from requests->pytapo) (2.1.1)
Installing collected packages: rtp, pytapo
  Attempting uninstall: pytapo
    Found existing installation: pytapo 2.8
    Uninstalling pytapo-2.8:
      Successfully uninstalled pytapo-2.8

Result: all good :)

Thanks a lot!

Bela