Skip to content

Commit f87a261

Browse files
committed
fix oauth2 token auto-refresh
1 parent 3dffc1d commit f87a261

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

openhab/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import logging
2424
import pathlib
2525
import re
26+
import time
2627
import typing
2728
import warnings
2829

@@ -89,6 +90,9 @@ def __init__(self, base_url: str,
8990
if self.oauth2_config is not None:
9091
self._validate_oauth2_config(self.oauth2_config)
9192

93+
if 'expires_at' not in self.oauth2_config['token']:
94+
self.oauth2_config['token']['expires_at'] = time.time() - 10
95+
9296
self.session = OAuth2Session(self.oauth2_config['client_id'],
9397
token=self.oauth2_config['token'],
9498
auto_refresh_url=f'{self.url_rest}/auth/token',

0 commit comments

Comments
 (0)