mezz64 / pyEight

Python library to interface with the Eight Sleep API
MIT License
59 stars 15 forks source link

Handle refresh token bug and add user profile data #20

Closed raman325 closed 3 years ago

raman325 commented 3 years ago

When I tried to fix the issue with fetching the token I didn't realize the refresh token process followed a similar code path. So now, I believe the initial token request and the refresh token request both use the fetch_token function so I have updated that token to pass a new parameter into the post call to prevent the token from getting added to the request.

I also:

mezz64 commented 3 years ago

I like the user info addition, but it seems to be static information so it would seem best to pull that once during setup rather than with the update user call since that pulls dynamic info about the user bed side and as a result gets called on a regular interval.

One of the original goals with this library was to minimize api calls as much as possible since it's not officially available for 3rd party use. I don't want to give Eight a reason to want to block things.

raman325 commented 3 years ago

That is a great point, I will be sure to do that. I also found another issue that sometimes occurs in my testing with the atexit call which I have just fixed.

mezz64 commented 3 years ago

Looks good. Thanks!

raman325 commented 2 years ago

your understanding is correct. I don't think anyone has identified how a refresh works (assuming it works at all). I tried sniffing around their API endpoint, you can make an OPTIONS request on valid endpoints and it will return the available methods for the endpoint. I tried /refresh and /token/refresh and those don't appear to be valid endpoints. Doesn't mean one doesn't exist, I just haven't found it yet.