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

Login access_token and refresh_token #57

Closed
mmalloy opened this issue Jun 23, 2021 · 4 comments
Closed

Login access_token and refresh_token #57

mmalloy opened this issue Jun 23, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@mmalloy
Copy link

mmalloy commented Jun 23, 2021

The response from the Wyzecam login API returns
'access_token': None, 'refresh_token': None
even though login appears to be successful.

Here's a minimum working example:

payload = {"email": email, "password": triplemd5(password)}                                                                                                                       
                                                                                                                                                                                  
resp = requests.post(                                                                                                                                                             
    "https://auth-prod.api.wyze.com/user/login",                                                                                                                                  
    json=payload,                                                                                                                                                                 
    headers=get_headers(phone_id)                                                                                                                                                 
)                                                                                                                                                                                 
                                                                                                                                                                                  
print(resp.json())   

{'access_token': None, 'refresh_token': None, 'user_id': 'fea576c0cXXXXXXXX978ddc792b50187', 'mfa_options': ['PrimaryPhone'], 'mfa_details': {'phone_numbers': {'primary_phone': {'country_code': '+1', 'number': 'XXXXXXXXXX'}, 'backup_phone': None}, 'totp_apps': []}, 'sms_session_id': 'XXXXXXXX-f07f-4314-9f56-488be33f302d'}
@github-actions
Copy link

Hello @mmalloy, thank you for your interest in our work!

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

@mmalloy
Copy link
Author

mmalloy commented Jun 24, 2021

A few more detail showing the error:

>>> import wyzecam
>>> auth_info = wyzecam.login(email, password)
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/wyzecam/api.py", line 49, in login
    return WyzeCredential.parse_obj(dict(resp.json(), phone_id=phone_id))
  File "pydantic/main.py", line 578, in pydantic.main.BaseModel.parse_obj
  File "pydantic/main.py", line 406, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 3 validation errors for WyzeCredential
access_token
  none is not an allowed value (type=type_error.none.not_allowed)
refresh_token
  none is not an allowed value (type=type_error.none.not_allowed)
mfa_options
  value is not a valid dict (type=type_error.dict)

@kroo
Copy link
Owner

kroo commented Jun 24, 2021

hey @mmalloy -- it looks like you have 2-factor authentication turned on (it's asking you to go through an extra step of auth, entering in a code via sms). I haven't personally figured out how this works, but I believe others have -- consider using https://github.com/shauntarves/wyze-sdk? It looks like you can get the access token from the Client object in that library via the _token attribute:

from wyze_sdk import Client
client = Client(username=..., password=..., totp_key=...)
access_token = client._token

@kroo kroo added the enhancement New feature or request label Jun 24, 2021
@mmalloy
Copy link
Author

mmalloy commented Jun 25, 2021

Thanks @kroo! That was certainly the issue. Just turning off the two-factor authentication took care of the problem.

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

No branches or pull requests

2 participants