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

Calling the client won't let me login #35

Closed
feliutg opened this issue Jul 22, 2021 · 9 comments
Closed

Calling the client won't let me login #35

feliutg opened this issue Jul 22, 2021 · 9 comments

Comments

@feliutg
Copy link

feliutg commented Jul 22, 2021

Seems something changed because I have an automation that log in automatically in my account and it stopped working. The password is fine and I can use the Wyze application as normal. Probably an API changed?

@JohnMTorgerson
Copy link
Contributor

JohnMTorgerson commented Jul 22, 2021

Same. This is what I'm getting now when I'm testing it (on my mac):

2021-07-22 18:40:05,114 : ERROR : main : WyzeApiError retrieving bulbs: Parameters passed to Wyze Service do not fit the endpoint
The server responded with: {'ts': 1626997204144, 'code': '1001', 'msg': 'ParameterError', 'data': {}}

But the error I get on my raspberry pi is different, for some reason, I have no idea why:

2021-07-22 00:48:02,606 : CRITICAL : main : Could not get client. Aborting: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "/home/pi/Projects/lighting-automation/src/main.py", line 49, in <module>
    raise e
  File "/home/pi/Projects/lighting-automation/src/main.py", line 46, in <module>
    client = Client(email=os.environ['WYZE_EMAIL'], password=os.environ['WYZE_PASSWORD'])
  File "/home/pi/.pyenv/versions/3.9.4/lib/python3.9/site-packages/wyze_sdk/api/client.py", line 59, in __init__
    self.login()
  File "/home/pi/.pyenv/versions/3.9.4/lib/python3.9/site-packages/wyze_sdk/api/client.py", line 139, in login
    response = self._auth_client().user_login(email=self._email, password=self._password, totp_key=self._totp_key)
  File "/home/pi/.pyenv/versions/3.9.4/lib/python3.9/site-packages/wyze_sdk/service/auth_service.py", line 79, in user_login
    if 'TotpVerificationCode' in response.get('mfa_options'):
TypeError: argument of type 'NoneType' is not iterable

That was the time of the first error, a little before 1am Central Daylight this morning. My cron job runs every 3 minutes, so it would have been within that time frame that something changed, I guess.

(Edit: the different errors I'm getting are probably because, I just realized, I have wyze-sdk 1.1.5 on my mac; raspberry pi is using 1.2.1; interesting that 1.1.5 is apparently still able to log into the client? Because it doesn't error out until after that line)

@taylorbernt0
Copy link

Same here. I've been using the same username and password and these are the headers that wyze_sdk is receiving after trying to login now:

{'Content-Type': 'application/json', 'Content-Length': '36', 'Connection': 'keep-alive', 'Date': 'Thu, 22 Jul 2021 23:54:21 GMT', 'x-amzn-RequestId': '689d8a8b-982e-4779-bfd8-0ca49dbd5cbe', 'x-amzn-ErrorType': 'ForbiddenException', 'x-amz-apigw-id': 'C5W_KEGBvHcFprg=', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 0fdea8d3b1fc76e3ff9d36e8164171e9.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'DEN52-C1', 'X-Amz-Cf-Id': 'AxGs1exqE4J9bm4K1fBLfXFHXWNMDHoiMMgYdG5qzknPXqYgVXbR7Q=='}

@taylorbernt0
Copy link

I found a temporary solution! Adding a user-agent header to the _get_headers function in auth_service.py works.
Example:

request_specific_headers.update({
            "user-agent": "wyze_android_2.11.40",   <----- This is the line to add
            'x-api-key': self.api_key,
})

@shauntarves
Copy link
Owner

shauntarves commented Jul 23, 2021 via email

@Antyos
Copy link

Antyos commented Jul 23, 2021

Thanks for the fix @taylorbernt0! I think I remember Wyze sent out an email a few weeks ago noting that they were dropping compatibility for older versions of their app for security reasons. Because of that, it would make sense that this small fix is the correct solution.

@JohnMTorgerson
Copy link
Contributor

JohnMTorgerson commented Jul 23, 2021

Thanks @taylorbernt0 that worked for me too, even though I don't understand a lick of what's going on there. If this is indeed the permanent solution you should do a pull request!

@TheGreatSkeeve
Copy link

Big thanks to @taylorbernt0 for that fix! That did the trick, I'm super excited to check out this client. Just bought so much Wyze stuff.

@shauntarves
Copy link
Owner

Hey all...I will get a permanent fix in for this shortly. I've got a handful of fixes piling up, just need a bit of time to work them.

@NewMountain
Copy link

@taylorbernt0 Totally worked for me as well. Thank you so much!

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

7 participants