nkgilley / python-ecobee-api

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

Add support for web-based login flow #78

Closed JJTech0130 closed 2 months ago

JJTech0130 commented 2 months ago

As of March 28th, 2024, ecobee is no longer accepting new developer subscriptions, nor are existing developer accounts able to create new API keys. There is no ETA for when they will be allowed again. Existing API keys will continue to function.

Ecobee is no longer accepting new developer subscriptions, so an alternative to the transitional API-key based login flow is necessary.

Ecobee's official web pages uses a slightly different 'Auth0' login flow, which is able to produce Bearer tokens which can work with python-ecobee-api

This is fairly straightforward:

A request needs to be made to https://auth.ecobee.com/authorize?response_type=token&response_mode=form_post&client_id=183eORFPlXyz9BbDZwqexHPBQoVjgadh&redirect_uri=https://www.ecobee.com/home/authCallback&audience=https://prod.ecobee.com/api/v1&scope=openid%20smartWrite%20piiWrite%20piiRead%20smartRead%20deleteGrants

Until its expiration, that Bearer token can be used the same as the token from the developer API. Note that there is no refresh token, you use the above API with the auth0 cookie in a similar manner.

If there are no objections to this approach, I plan to create a PR soon.