login: add support for north america
This commit is contained in:
13
hc-login.py
13
hc-login.py
@@ -44,7 +44,10 @@ session = requests.Session()
|
|||||||
session.headers.update(headers)
|
session.headers.update(headers)
|
||||||
|
|
||||||
base_url = "https://api.home-connect.com/security/oauth/"
|
base_url = "https://api.home-connect.com/security/oauth/"
|
||||||
asset_url = "https://prod.reu.rest.homeconnectegw.com/"
|
asset_urls = [
|
||||||
|
"https://prod.reu.rest.homeconnectegw.com/", # EU
|
||||||
|
"https://prod.rna.rest.homeconnectegw.com/", # US
|
||||||
|
]
|
||||||
|
|
||||||
#
|
#
|
||||||
# Start by fetching the old login page, which gives
|
# Start by fetching the old login page, which gives
|
||||||
@@ -247,8 +250,14 @@ headers = {
|
|||||||
"Authorization": "Bearer " + token,
|
"Authorization": "Bearer " + token,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Try to request account details from all geos. Whichever works, we'll use next.
|
||||||
|
for asset_url in asset_urls:
|
||||||
|
r = requests.get(asset_url + "account/details", headers=headers)
|
||||||
|
if r.status_code == requests.codes.ok:
|
||||||
|
break
|
||||||
|
|
||||||
# now we can fetch the rest of the account info
|
# now we can fetch the rest of the account info
|
||||||
r = requests.get(asset_url + "account/details", headers=headers)
|
|
||||||
if r.status_code != requests.codes.ok:
|
if r.status_code != requests.codes.ok:
|
||||||
print("unable to fetch account details", file=sys.stderr)
|
print("unable to fetch account details", file=sys.stderr)
|
||||||
print(r.headers, r.text)
|
print(r.headers, r.text)
|
||||||
|
|||||||
Reference in New Issue
Block a user