You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(auth)!: Implement new OAuth device code grant flow (#478)
* feat(auth)!: Implement new OAuth device code grant flow
This commit introduces the new device code grant flow introduced
by Tado and required as of 2025-03-21.
The changes are highly based on python-tado, release 0.18.9
See: https://github.com/wmalgadey/PyTado/commits/0.18.9/
For more information about the change by Tado,
See: https://support.tado.com/en/articles/8565472-how-do-i-authenticate-to-access-the-rest-api
BREAKING CHANGE: Tado does not support password grant flow as authentication flow anymore.
* chore: uncomment useful call in example
* fix(auth): Create token file when absent to avoir errors
* chore: Update .env.template file
* fix(cli): Manage mutually exclusive cli arguments
* ci: Remove matric strategy on python versions
* ci: Remove matric strategy on python versions
* ci: Remove matric strategy on python versions
* fix(cli): Manage mutually exclusive cli arguments
* chore(lint): Ruff linter
* chore(lint): Yaml linter
* docs: Add page to explain what are why about new auth flow
* docs: Update tado generated jsonschemas
* docs: Update readme with warning banner
* ci: Disable unit tests job
---------
Co-authored-by: Arjan Vlek <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+50-29
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,15 @@ A library to control your Tado Smart Thermostat. This repository contains an act
14
14
15
15
**The tested version of APIs is Tado v2.**
16
16
17
+
## ⚠️ Breaking change in v4 ⚠️
18
+
19
+
Starting the **21st of March 2025**, the Tado authentication workflow will definitely change to OAuth2 device code grant flow.
20
+
21
+
Here is the link to the official announcement: [Tado Support Article - How do I authenticate to access the REST API?](https://support.tado.com/en/articles/8565472-how-do-i-authenticate-to-access-the-rest-api)
22
+
23
+
Now, you have to use the `TADO_CREDENTIALS_FILE` or `TADO_REFRESH` variables to authenticate.
24
+
You can find more documentation on how to authenticate in the [**Libtado - CLI Configuration**](https://libtado.readthedocs.io/en/latest/cli/configuration/) documentation.
25
+
17
26
## Installation
18
27
19
28
You can download official library with `pip install libtado`.
It is recommended to use a directory that only your application has access to, as the credentials file
45
+
holds sensitive information!
45
46
46
-
An alternative way to get your `CLIENT_SECRET` is to enable the Developper Mode when logging in and catch the Headers. You will find the form data like this :
import webbrowser # only needed for direct web browser access
56
52
57
-
Then you just have to get the value in the attribute `client_secret`. You will need it to connect to your account through Tado APIs. The `client_secret` never dies so you can base your script on it.
53
+
#TODO check
54
+
t = api.Tado(token_file='/tmp/.libtado_refresh_token.json')
55
+
# OR: t = api.Tado(saved_refresh_token='my_refresh_token')
58
56
59
-
## Usage
57
+
status = t.get_device_activation_status()
60
58
61
-
Download the repository. You can work inside it. Beware that the examples assume that they can access the file `./libtado/api.py`.
59
+
if status =="PENDING":
60
+
url = t.get_device_verification_url()
62
61
63
-
Now you can call it in your Pyhton script!
62
+
# to auto-open the browser (on a desktop device), un-comment the following line:
Copy file name to clipboardExpand all lines: docs/cli/configuration.md
+10-3
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# CLI Configuration
2
2
3
+
!!! warning
4
+
5
+
The variables `TADO_USERNAME` and `TADO_PASSWORD` and `TADO_CLIENT_SECRET` are deprecated. Use `TADO_CREDENTIALS_FILE` or `TADO_REFRESH_TOKEN` instead.
6
+
3
7
## Configuration File
4
8
5
9
There is no configuration file. No need.
@@ -8,9 +12,12 @@ There is no configuration file. No need.
8
12
9
13
The following environment variables are supported:
10
14
11
-
*`TADO_USERNAME` - Tado username
12
-
*`TADO_PASSWORD` - Tado password
13
-
*`TADO_CLIENT_SECRET` - Tado client secret
15
+
*`TADO_CREDENTIALS_FILE` - Path to a file which holds your Tado credentials. Be careful: do not share this file with others.
16
+
*`TADO_REFRESH_TOKEN` - Tado refresh token, from previous login. Valid for one-time use only.
17
+
18
+
!!! note
19
+
20
+
The variables `TADO_CREDENTIALS_FILE` and `TADO_REFRESH_TOKEN` are mutually exclusive. If both are set, an error will be raised.
14
21
15
22
Environment variables can be set up in multiples ways:
## Why variables `TADO_USERNAME` and `TADO_PASSWORD` are not working anymore?
4
4
5
-
### Option #1: Do nothing
5
+
Starting the 21st of March 2025, the Tado authentication workflow will definitely change to OAuth2 device code grant flow.
6
6
7
-
The library wil automatically retrieve the client secret on following the steps at *Options #2*.
7
+
!!! info
8
8
9
-
### Option #2: From the application `env.js`
9
+
Here is the link to the official announcement: [Tado Support Article - How do I authenticate to access the REST API?](https://support.tado.com/en/articles/8565472-how-do-i-authenticate-to-access-the-rest-api)
10
10
11
-
Retrieve the `CLIENT_SECRET` before running the script otherwise you will get a `401 Unauthorized Access`. The latest `CLIENT_SECRET` can be found at \[<https://my.tado.com/webapp/env.js>\](<https://my.tado.com/webapp/env.js>). It will look something like this:
11
+
The direction that Tado is taking is to enforce security and privacy by using OAuth2. This is a good thing, as it will prevent the need to store your username and password in plain text in your environment variables.
12
+
But the consequences of that change are that library handles differently the authentication process.
12
13
13
-
### Option #3: From the developer mode
14
+
!!! warning
14
15
15
-
An alternative way to get your `CLIENT_SECRET` is to enable the Developper Mode when logging in and catch the Headers. You will find the form data like this:
16
+
Now, you have to use the `TADO_CREDENTIALS_FILE` or `TADO_REFRESH` variables to authenticate.
Then you just have to get the value in the attribute `client_secret`. You will need it to connect to your account through Tado APIs. The `client_secret` never dies so you can base your script on it.
18
+
You can find more documentation on how to authenticate in the [**CLI Configuration**](./cli/configuration.md) section.
**libtado** is a simple Python library that provides methods to control the smart heating devices from the German company [tado GmbH](https://www.tado.com)[^1]. It uses the undocumented REST API of their website.
18
18
@@ -22,7 +22,7 @@ The source code is hosted on [GitHub](https://github.com/germainlefebvre4/libtad
> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
0 commit comments