login: add support for north america

This commit is contained in:
Alexey Manukhin
2024-05-10 01:03:49 -04:00
parent 50dbc6e64b
commit 178871b031

View File

@@ -44,7 +44,10 @@ session = requests.Session()
session.headers.update(headers)
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
@@ -247,8 +250,14 @@ headers = {
"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
r = requests.get(asset_url + "account/details", headers=headers)
if r.status_code != requests.codes.ok:
print("unable to fetch account details", file=sys.stderr)
print(r.headers, r.text)