Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 400 Client Error: Bad Request on Login #72

Open
drewdah opened this issue Sep 14, 2023 · 3 comments
Open

[BUG] 400 Client Error: Bad Request on Login #72

drewdah opened this issue Sep 14, 2023 · 3 comments

Comments

@drewdah
Copy link

drewdah commented Sep 14, 2023

Describe the bug
I've had this addon installed for a few months, but recently it stopped working. I tried reloading the addon and it would fail to start, so I tried to uninstall / reinstall and when I entered my wyze credentials and the key id / auth key. I got "Problems Logging in. Please verify your username and password". I checked my username/password and the API keys and they are correct, I even tried creating a new API key with Wyze to see if that solved the problem, but it did not.

To Reproduce
Steps to reproduce the behavior:

  1. Install simple-wyze-vac via HACS
  2. Go to Settings -> Devices -> Add Integration and select "Simple Wyze Vac"
  3. Enter your username/password, API key id and API key auth
  4. See "Problems Logging in" error

Expected behavior
I expected the integration to log me in and create my wyze vacuum entities

Screenshots
login-error-screenshot

Simple Wyze Vac Version

  • 1.8.9

Wyze Vacuum Firmware Version

  • 1.6.202

Home Assistant Version

  • 2023.9.2

Additional context
The following error logs were visible in Settings -> System -> Logs that might be useful

This error originated from a custom integration.

Logger: homeassistant.config_entries
Source: custom_components/simple_wyze_vac/__init__.py:52
Integration: Simple Wyze Vac (documentation)
First occurred: 1:21:18 PM (3 occurrences)
Last logged: 2:33:32 PM

Error setting up entry Simple Wyze Vac for simple_wyze_vac
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/simple_wyze_vac/__init__.py", line 52, in async_setup_entry
    client = await hass.async_add_executor_job(Client, None, None, username, password, key_id, api_key, totp)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/api/client.py", line 72, in __init__
    self.login()
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/api/client.py", line 184, in login
    response = self._auth_client().user_login(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/service/auth_service.py", line 88, in user_login
    response = self.api_call(
               ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/service/auth_service.py", line 58, in api_call
    return super().api_call(
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/service/base.py", line 347, in api_call
    return super().api_call(
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/service/base.py", line 204, in api_call
    return self.do_post(url=api_url, headers=headers, payload=json, params=params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/service/base.py", line 132, in do_post
    return self._do_request(client, req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/service/base.py", line 106, in _do_request
    raise err
  File "/usr/local/lib/python3.11/site-packages/wyze_sdk/service/base.py", line 93, in _do_request
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://auth-prod.api.wyze.com/api/user/login
This error originated from a custom integration.

Logger: custom_components.simple_wyze_vac.config_flow
Source: custom_components/simple_wyze_vac/config_flow.py:55
Integration: Simple Wyze Vac (documentation)
First occurred: 2:36:49 PM (2 occurrences)
Last logged: 2:54:39 PM

Failed to login Wyze servers.
@romedtino
Copy link
Owner

Have you tried logging in again? I've seen this reported occasionally and it seems to resolve itself on its own and I'm suspecting some part of the Wyze servers went down and prevented access? Though Error 400 is usually saying its the requestor that's the problem.

The hard part is that the error stems from wyze-sdk which is trying to reach out to the Wyze servers so the issue is either the information you're providing for logging in or the Wyze servers themselves.

@drewdah
Copy link
Author

drewdah commented Sep 15, 2023

I tried a few times when writing up the bug to grab screenshots and just tried again now this morning and got the same error. I'm able to log into the wyze.com site with the same copy/pasted username and password, so I tried deleting my API key again and creating a new one and that seems to have solved it.

Maybe Wyze is invalidating or blocking keys? I know they rate limit if we poll too often

@Tadimsky
Copy link

I just ran into this same issue after setting it up yesterday, today it's failing with the same 400 error.
Once you re-generated the token did it continue working for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants