Skip to content

Commit 2e3fb7f

Browse files
fix(login): Add library name in UserAgent on Tado requests (#300)
* chore(login): Add lib name and version in useragent * chore(login): Add deps packages * chore: Bump version * chore: Remove Pipfile in favor of poetry
1 parent c80ea0a commit 2e3fb7f

File tree

6 files changed

+22
-33
lines changed

6 files changed

+22
-33
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ jobs:
1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
22-
pip install -r requirements_test.txt
22+
pip install -r requirements.txt
23+
pip install pytest pytest-dotenv
2324
- name: Set .env.test file
2425
run: |
2526
cat << EOF > .env.test

Pipfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

libtado/api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,23 @@ def __init__(self, username, password, secret):
5555
def _login(self):
5656
"""Login and setup the HTTP session."""
5757
url='https://auth.tado.com/oauth/token'
58+
headers = { 'User-Agent': 'python/libtado' }
5859
data = { 'client_id' : 'tado-web-app',
5960
'client_secret' : self.secret,
6061
'grant_type' : 'password',
6162
'password' : self.password,
6263
'scope' : 'home.user',
6364
'username' : self.username }
64-
request = requests.post(url, data=data, timeout=self.timeout)
65+
request = requests.post(url, headers=headers, data=data, timeout=self.timeout)
6566
request.raise_for_status()
6667
response = request.json()
6768
self.access_token = response['access_token']
6869
self.token_expiry = time.time() + float(response['expires_in'])
6970
self.refresh_token = response['refresh_token']
70-
self.access_headers = {'Authorization': 'Bearer ' + response['access_token']}
71+
self.access_headers = {
72+
'Authorization': 'Bearer ' + response['access_token'],
73+
'User-Agent': 'python/libtado',
74+
}
7175

7276
def _api_call(self, cmd, data=False, method='GET'):
7377
"""Perform an API call."""

poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "libtado"
3-
version = "3.5.1"
3+
version = "3.7.13"
44
description = "A library (and a command line client) to control your Tado Smart Thermostat."
55
authors = ["Germain Lefebvre <germain.lefebvre4@gmail.com>"]
66
license = "GNU GPL v3.0"
@@ -18,6 +18,7 @@ classifiers = [
1818
python = ">=3.8.1,<4.0"
1919
click = "*"
2020
requests = "*"
21+
python-dateutil = "2.8.2"
2122

2223
[tool.poetry.group.test.dependencies]
2324
poetry-plugin-dotenv = "^0.5.0"

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ colorama==0.4.6 ; python_full_version >= "3.8.1" and python_version < "4.0" and
101101
idna==3.4 ; python_full_version >= "3.8.1" and python_version < "4.0" \
102102
--hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \
103103
--hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2
104+
python-dateutil==2.8.2 ; python_full_version >= "3.8.1" and python_version < "4.0" \
105+
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
106+
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
104107
requests==2.31.0 ; python_full_version >= "3.8.1" and python_version < "4.0" \
105108
--hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \
106109
--hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1
110+
six==1.16.0 ; python_full_version >= "3.8.1" and python_version < "4.0" \
111+
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
112+
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
107113
urllib3==2.0.6 ; python_full_version >= "3.8.1" and python_version < "4.0" \
108114
--hash=sha256:7a7c7003b000adf9e7ca2a377c9688bbc54ed41b985789ed576570342a375cd2 \
109115
--hash=sha256:b19e1a85d206b56d7df1d5e683df4a7725252a964e3993648dd0fb5a1c157564

0 commit comments

Comments
 (0)