1
0
mirror of https://github.com/no2chem/wideq.git synced 2025-05-17 07:40:09 -07:00

Extract new access token

This commit is contained in:
Adrian Sampson 2018-01-20 16:54:53 -05:00
parent 8653810e0d
commit 0648876cc0

View File

@ -55,6 +55,13 @@ class NotLoggedInError(APIError):
pass pass
class TokenError(APIError):
"""An authentication token was rejected."""
def __init__(self):
pass
def lgedm_post(url, data=None, access_token=None, session_id=None): def lgedm_post(url, data=None, access_token=None, session_id=None):
"""Make an HTTP request in the format used by the API servers. """Make an HTTP request in the format used by the API servers.
@ -232,10 +239,13 @@ class Auth(object):
'lgemp-x-date': timestamp, 'lgemp-x-date': timestamp,
'Accept': 'application/json', 'Accept': 'application/json',
} }
print(headers)
res = requests.post(token_url, data=data, headers=headers) res = requests.post(token_url, data=data, headers=headers)
print(res.text) res_data = res.json()
if res_data['status'] != 1:
raise TokenError()
return res_data['access_token']
class Session(object): class Session(object):