Skip to content

Commit 6073c26

Browse files
authored
correcting use off access Token
1 parent 16c2d20 commit 6073c26

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lnetatmo.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Multiple contributors : see https://github.com/philippelt/netatmo-api-python
44
# License : GPL V3
55
"""
6-
This API provides access to the Netatmo weather station or/and the Welcome camera
6+
This API provides access to the Netatmo weather station or/and other installed devices
77
This package can be used with Python2 or Python3 applications and do not
88
require anything else than standard libraries
99
@@ -210,12 +210,14 @@ class ClientAuth:
210210

211211
def __init__(self, clientId=None,
212212
clientSecret=None,
213+
accessToken=None,
213214
refreshToken=None,
214215
credentialFile=None):
215216

216217
# replace values with content of env variables if defined
217218
clientId = getenv("CLIENT_ID", clientId)
218219
clientSecret = getenv("CLIENT_SECRET", clientSecret)
220+
accessToken = getenv("ACCESS_TOKEN", accessToken)
219221
refreshToken = getenv("REFRESH_TOKEN", refreshToken)
220222

221223
# Look for credentials in file if not already provided
@@ -232,9 +234,9 @@ def __init__(self, clientId=None,
232234

233235
self._clientId = clientId or cred["CLIENT_ID"]
234236
self._clientSecret = clientSecret or cred["CLIENT_SECRET"]
237+
self._accessToken = accessToken or cred["ACCESS_TOKEN"] # Will be refreshed before any use
235238
self.refreshToken = refreshToken or cred["REFRESH_TOKEN"]
236239
self.expiration = 0 # Force refresh token
237-
self._accessToken = None # Will be refreshed before any use
238240

239241
@property
240242
def accessToken(self):
@@ -253,6 +255,7 @@ def renew_token(self):
253255
self.refreshToken = resp['refresh_token']
254256
cred = {"CLIENT_ID":self._clientId,
255257
"CLIENT_SECRET":self._clientSecret,
258+
"ACCESS_TOKEN" : self._accessToken,
256259
"REFRESH_TOKEN":self.refreshToken }
257260
if self._credentialFile:
258261
with open(self._credentialFile, "w", encoding="utf-8") as f:
@@ -1007,16 +1010,16 @@ def __init__(self, authData):
10071010
# homecoach data
10081011
if not self.rawData : raise NoDevice("No HomeCoach available")
10091012

1010-
def HomecoachDevice(self, id=""):
1013+
def HomecoachDevice(self, hid=""):
10111014
for device in self.rawData:
1012-
if id == device['_id']:
1015+
if hid == device['_id']:
10131016
return device
10141017
return None
10151018

1016-
def Dashboard(self, id=""):
1019+
def Dashboard(self, hid=""):
10171020
#D = self.HomecoachDevice['dashboard_data']
10181021
for device in self.rawData:
1019-
if id == device['_id']:
1022+
if hid == device['_id']:
10201023
D = device['dashboard_data']
10211024
return D
10221025

0 commit comments

Comments
 (0)