piekstra/tplink-cloud-api

Login and connection issues

Opened this issue · 0 comments

Hi

I am trying for a poc for my smart plug tapo p110 and kp115 plugs and found your library.
when i tried the below code i see issues, i am not into low level programming and lost in errors, it would be great if someone can help understand the issue and direct or let me know how to have these issues resolved.

code snippet as below:
++++++++++++++++++++
import asyncio

from tplinkcloud import TPLinkDeviceManager

username = 'xxxxxxxxxx'
password = 'xxxxxx'

device_manager = TPLinkDeviceManager(username, password)

async def getAllDevices():
devices = await device_manager.get_devices()
if devices:
print(f"Found {len(devices)} devices")
for device in devices:
print(f"{device.model_type.name} called as {device.get_alias()}")

asyncio.run(getAllDevices())

+++++++++++++++++++++++++++++++++++++++++++

Below is the list of errors:

Traceback (most recent call last):
File "../projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 468, in _make_request
self._validate_conn(conn)
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 1097, in _validate_conn
conn.connect()
File "../projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 658, in connect
assert_fingerprint=self.assert_fingerprint,
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 793, in ssl_wrap_socket_and_match_hostname
tls_in_tls=tls_in_tls,
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/util/ssl
.py", line 471, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/util/ssl
.py", line 515, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 423, in wrap_socket
session=session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 870, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 803, in urlopen
**response_kw,
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 492, in _make_request
raise new_e
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/requests/adapters.py", line 497, in send
chunked=chunked,
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 846, in urlopen
method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 515, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='wap.tplinkcloud.com', port=443): Max retries exceeded with url: /?appName=Kasa_Android&termID=ea0cbffe-1275-457e-8d3d-4a5984966465&appVer=1.4.4.607&ospf=Android%2B6.0.1&netType=wifi&locale=es_ES (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "..projOne/pythonProject1/deviceDiscov2.py", line 8, in
device_manager = TPLinkDeviceManager(username, password)
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/tplinkcloud/device_manager.py", line 40, in init
self.login(username, password)
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/tplinkcloud/device_manager.py", line 109, in login
auth_token = self._tplink_api.login(username, password)
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/tplinkcloud/client.py", line 75, in login
response = self._request_post(body)
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/tplinkcloud/client.py", line 45, in _request_post
headers=self._headers
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "..projOne/pythonProject1/.venv/lib/python3.7/site-packages/requests/adapters.py", line 517, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='wap.tplinkcloud.com', port=443): Max retries exceeded with url: /?appName=Kasa_Android&termID=ea0cbffe-1275-457e-8d3d-4a5984966465&appVer=1.4.4.607&ospf=Android%2B6.0.1&netType=wifi&locale=es_ES (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))

Process finished with exit code 1