SecKatie / ha-wyzeapi

Home Assistant Integration for Wyze devices.
740 stars 112 forks source link

[Bug] Integration cannot login to Wyze #498

Closed ubergeek10 closed 1 year ago

ubergeek10 commented 1 year ago

Describe the bug When installing the Wyze integration, my Wyze credentials are filled in via BitWarden (so I know they are correct) but the integrated throws an error. “Unknown error occurred.”

To Reproduce Steps to reproduce the behavior:

  1. Click on add integration
  2. Enter username and password
  3. Press submit
  4. See error

Expected behavior The integration should install.

System configuration System: HASS HA Version: 2023.7.3 WyzeApi Version: latest version

home-assistant.log


This error originated from a custom integration.

Logger: aiohttp.server
Source: custom_components/wyzeapi/config_flow.py:59 
Integration: Wyze Home Assistant Integration (documentation, issues) 
First occurred: 8:38:46 AM (1 occurrences) 
Last logged: 8:38:46 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 297, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 393, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wyzeapi/config_flow.py", line 59, in async_step_user
    await self.client.login(
  File "/usr/local/lib/python3.11/site-packages/wyzeapy/__init__.py", line 81, in login
    await self._auth_lib.get_token_with_username_password(email, password)
  File "/usr/local/lib/python3.11/site-packages/wyzeapy/wyze_auth_lib.py", line 104, in get_token_with_username_password
    response_json = await self.post("https://auth-prod.api.wyze.com/user/login", headers=headers,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyzeapy/wyze_auth_lib.py", line 232, in post
    return await response.json()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8', url=URL('https://auth-prod.api.wyze.com/user/login')
Evlmoonkey commented 1 year ago

Same issue here, Token Error...

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 390, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/wyzeapi/init.py", line 121, in async_setup_entry mac_addresses = await client.unique_device_ids ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/wyzeapy/init.py", line 138, in unique_device_ids devices = await self._service.get_object_list() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/wyzeapy/services/base_service.py", line 122, in get_object_list check_for_errors_standard(response_json) File "/usr/local/lib/python3.11/site-packages/wyzeapy/utils.py", line 80, in check_for_errors_standard raise AccessTokenError wyzeapy.exceptions.AccessTokenError 2023-07-29 09:37:21.852 DEBUG (MainThread) [wyzeapy.wyze_auth_lib] Request: 2023-07-29 09:37:21.852 DEBUG (MainThread) [wyzeapy.wyze_auth_lib] url: https://api.wyzecam.com/app/v2/home_page/get_object_list 2023-07-29 09:37:21.852 DEBUG (MainThread) [wyzeapy.wyze_auth_lib] json: {'phone_system_type': '1', 'app_version': '2.18.43', 'app_ver': 'com.hualai.WyzeCam___2.18.43', 'sc': '9f275790cab94a72bd206c8876429f3c', 'ts': 1690641438, 'sv': '9d74946e652647e9b6c9d59326aef104', 'access_token': 'Sanitized', 'phone_id': '74d171c0-243c-423c-9747-1b545a9e375b', 'app_name': 'com.hualai.WyzeCam'} 2023-07-29 09:37:21.852 DEBUG (MainThread) [wyzeapy.wyze_auth_lib] headers: None 2023-07-29 09:37:21.852 DEBUG (MainThread) [wyzeapy.wyze_auth_lib] data: None 2023-07-29 09:37:21.852 DEBUG (MainThread) [wyzeapy.wyze_auth_lib] Response Json: {'ts': 1690641439902, 'code': '2001', 'msg': 'AccessTokenError', 'data': {}} 2023-07-29 09:37:21.874 ERROR (MainThread) [custom_components.wyzeapi.token_manager] TokenManager detected a login issue please re-login. 2023-07-29 09:37:21.899 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up wyzeapi platform for sensor Traceback (most recent call last): File "/config/custom_components/wyzeapi/token_manager.py", line 45, in inner_function await func(*args, **kwargs) File "/config/custom_components/wyzeapi/sensor.py", line 44, in async_setup_entry locks = await lock_service.get_locks() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/wyzeapy/services/lock_service.py", line 34, in get_locks self._devices = await self.get_object_list() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/wyzeapy/services/base_service.py", line 122, in get_object_list check_for_errors_standard(response_json) File "/usr/local/lib/python3.11/site-packages/wyzeapy/utils.py", line 80, in check_for_errors_standard raise AccessTokenError wyzeapy.exceptions.AccessTokenError

NetDude12 commented 1 year ago

These are known issues and there appears to be some fixes on the way. Hope this helps

493

497

https://github.com/SecKatie/wyzeapy/pull/70

bfish2 commented 1 year ago

I'm having same issue, too.

James62370 commented 1 year ago

Same here... I was not able to login again without deleting the integration and re-adding After this I was prompted with a login option which included ID and API Key. After a successful login, you need to put your devices back in it's proper area. Automations still worked. Good luck everyone.

ubergeek10 commented 1 year ago

Yes I have updated to the new version and, after generating the Wyze API key, was able to login again. It all works as expected. Great job!

From: James62370 @.> Date: Thursday, August 3, 2023 at 2:09 PM To: SecKatie/ha-wyzeapi @.> Cc: ubergeek10 @.>, Author @.> Subject: Re: [SecKatie/ha-wyzeapi] [Bug] Integration cannot login to Wyze (Issue #498)

Same here... I was not able to login again without deleting the integration and re-adding After this I was prompted with a login option which included ID and API Key. After a successful login, you need to put your devices back in it's proper area. Automations still worked. Good luck everyone.

— Reply to this email directly, view it on GitHubhttps://github.com/SecKatie/ha-wyzeapi/issues/498#issuecomment-1664491153, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AV2BXEQRVTUBS33LCDANP5TXTPZOBANCNFSM6AAAAAA24QSTA4. You are receiving this because you authored the thread.Message ID: @.***>