nkgilley / python-ecobee-api

Python API for controlling Ecobee Thermostats
MIT License
44 stars 40 forks source link

Add token refresh support to request calls #70

Closed bjpetit closed 2 years ago

bjpetit commented 2 years ago

I'd like to propose a change where refresh_tokens can be called from within the library's request calls. The following code will watch for an ExpiredTokenError. If this exception is seen the request call will kick the refresh_tokens and try the request again. If the second call fails the exception will be passed up the stack. This is handled by a wrapper function around the _request call. This way the authentication and token handling can still use the existing logic. This PR also bumps up the requests version in the install_requires list.