shauntarves/wyze-sdk

Lost

Closed this issue · 7 comments

Hi
I am trying to reconfigure my python scripts for the new API authentication model. I am lost as to where to start. Thanks for any help to get me over the hump.

Will

Hi Will, there are a few steps now:

First, create a Wyze API key on their website and note/store the key id and the actual key: https://developer-api-console.wyze.com/#/apikey/view

Then, you need to provide these two new strings to the wyze-sdk via your scripts. The exact details will vary depending on how you've configured your scripts that use this wyze-sdk, but essentially, you need to provide them when calling the login method (if you use that) or when creating the client:

response = Client().login(
    email=os.environ['WYZE_EMAIL'],
    password=os.environ['WYZE_PASSWORD'],
    key_id=os.environ['WYZE_KEY_ID'], <-- new key_id data from the first step
    api_key=os.environ['WYZE_API_KEY'] <-- new api_key data from the first step
)

If you don't store these fields as environment variables, then just put the string values in the call above

Oh, I think there's some confusion about what the login call does.

There are two ways to make a usable client...you can either call the Client() constructor with all the account parameters or you can do a login() call first to get an access token and then provide that access token to the Client() constructor.

I think the easiest approach for you will be to just create a client and let the SDK do the work for you. Also, just based on what you pasted in your comment, you may not be using environment variables correctly. Start simple, and just set the fields directly in that Client() constructor:

...
client = Client(
    email='<your email>',
    password='<your password>',
    key_id='<your key id>',
    api_key='<your api key>'
)
...
client.vacuum.xxx

Thanks Shaun,

I did try that and received the error:
TypeError: Client.init() got an unexpected keyword argument 'key_id'