Hydro-Quebec-API-Wrapper 4.3.1__py3-none-any.whl → 4.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Hydro-Quebec-API-Wrapper
3
- Version: 4.3.1
3
+ Version: 4.4.0
4
4
  Summary: A wrapper library to access hydro quebec API and more
5
5
  Home-page: https://hydroqc.ca
6
6
  Author-email: Hydroqc Team <info@hydroqc.ca>
@@ -1,4 +1,4 @@
1
- hydro_quebec_api_wrapper-4.3.1.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
1
+ hydro_quebec_api_wrapper-4.4.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
2
2
  hydroqc/__init__.py,sha256=sFhCh7-LWoISCQuAtdrLQOmj2x5wjHBGbAAPg4SN6Pc,40
3
3
  hydroqc/account.py,sha256=84PO2npB_VG8cEzGIbmXj9sD1whG8qynkiGd-yEYddM,3375
4
4
  hydroqc/consts.py,sha256=CcqeInTfcpBe-u1-KGHUHd2SVv6Hq_27I8vLW5W53oM,768
@@ -10,7 +10,7 @@ hydroqc/public_client.py,sha256=pUXA9rkgA8b4wIA3EMsd8FAC-swp-IRa4S-VK0v60SQ,3065
10
10
  hydroqc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  hydroqc/timerange.py,sha256=MXR9yau72m4UZBSmN1qB0jMs0x4_jEZYnwtaUnGq-MQ,1137
12
12
  hydroqc/utils.py,sha256=sxA5qkOA-Ui5jgEYItFQIeQdBsS_5z8J3xn8YxKZMow,232
13
- hydroqc/webuser.py,sha256=2NiRoGB9yA5xvmHbNQV2DOhtn7o5ueG4cSjQv13ccKU,7206
13
+ hydroqc/webuser.py,sha256=LO7_ehJbCObSPFt7j6xlkCN_ATKDLXrTHy798E6YrlU,7469
14
14
  hydroqc/contract/__init__.py,sha256=uqxjOgyhpKFd-n_umxdaW5FB_DkJJaettWnEFC0nRYc,548
15
15
  hydroqc/contract/common.py,sha256=xVw9z_Yjqp95SGCPNAfJVABvgp_C-KM51VTBEU9wjeM,15705
16
16
  hydroqc/contract/contract_d.py,sha256=6jPYTCjFq8zonfbXPrEujDVz58n5RUEuq54VCGqph6o,856
@@ -23,8 +23,8 @@ hydroqc/contract/contract_residential.py,sha256=v88mWvJsJP7FsY5cHmr0ZYYT_S-6xtSk
23
23
  hydroqc/contract/outage.py,sha256=K5XX0enSKMVpL-JCkWsykuKUw-5_GcSJLzcSR1SqQDk,3979
24
24
  hydroqc/hydro_api/__init__.py,sha256=bIIjTkhQcXG7kn4cQr_Q6tFSKGjAx-AXLjMMlRCjclY,32
25
25
  hydroqc/hydro_api/cache.py,sha256=14nLVxV8Q2d9qnEi2iKK9exkhe5WCFueGu9uX5y_tyU,1716
26
- hydroqc/hydro_api/client.py,sha256=ECJglDk2hTvmKX_JHux2qcnBtSo2mpF-afR-FSOUPQQ,59272
27
- hydroqc/hydro_api/consts.py,sha256=XDNOjZVpC-Z7rsOL4GDgfexb7m8zc7HiafiKGiFvoUI,4607
26
+ hydroqc/hydro_api/client.py,sha256=iiO3e2gbBZugL2Xb0Va_J_Slkkxr4M40gXnh_wl4V0M,61065
27
+ hydroqc/hydro_api/consts.py,sha256=oH3sKhLcPzKeUeMzqVCZwpF1rWuDtYcycNrFX_nLYn0,6693
28
28
  hydroqc/hydro_api/mfa.py,sha256=UDfmXHjb4l5ggM1K9noAUQy2kO_yLZBHB-fqnUwtSx0,27825
29
29
  hydroqc/peak/__init__.py,sha256=ye2KbWXhJEHZnBDaFylWioy3W-mzJw_lDplsJNAapNs,19
30
30
  hydroqc/peak/basepeak.py,sha256=DMXjZXyNRHWnuhB0Vp3ZINGhNQngG7AU15cDLajmC7M,1954
@@ -47,8 +47,8 @@ hydroqc/types/cpc.py,sha256=ghmtBTT1FKuqVodJJ0kCtUbYNTLCOrngxgcrzjJYvok,2116
47
47
  hydroqc/types/dpc.py,sha256=mwA5T9fGcNTA-kb_f25wq2ALJCwa5lKABOS73L6znY0,1981
48
48
  hydroqc/types/dt.py,sha256=rEXDgNewhlOsRbso0Shlq69TvJFoT56EGYOAjTFZU80,693
49
49
  hydroqc/types/outage.py,sha256=XTsNyu8mmxUx44XWvOOUHKSoijp-lgbXwQroiqm9S0o,3932
50
- hydro_quebec_api_wrapper-4.3.1.dist-info/METADATA,sha256=bPzqj7e4hzyIJdl4L2sB1dEK6Q4lxlSfEzK5M2J1Hhs,10017
51
- hydro_quebec_api_wrapper-4.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
- hydro_quebec_api_wrapper-4.3.1.dist-info/entry_points.txt,sha256=G2YKkCH9rFt2dXbFyHINBp4bmqY2HTEIaf7F1CwbC_k,57
53
- hydro_quebec_api_wrapper-4.3.1.dist-info/top_level.txt,sha256=YAcYLnu5YYkbxt1psUoBfo_opl-lAZKq0A7B3IN_P6M,8
54
- hydro_quebec_api_wrapper-4.3.1.dist-info/RECORD,,
50
+ hydro_quebec_api_wrapper-4.4.0.dist-info/METADATA,sha256=JuS4QqgjIEYtqYo2MmeWtIS5FjSa8nD15Sdmw0IQ8EY,10017
51
+ hydro_quebec_api_wrapper-4.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
+ hydro_quebec_api_wrapper-4.4.0.dist-info/entry_points.txt,sha256=G2YKkCH9rFt2dXbFyHINBp4bmqY2HTEIaf7F1CwbC_k,57
53
+ hydro_quebec_api_wrapper-4.4.0.dist-info/top_level.txt,sha256=YAcYLnu5YYkbxt1psUoBfo_opl-lAZKq0A7B3IN_P6M,8
54
+ hydro_quebec_api_wrapper-4.4.0.dist-info/RECORD,,
@@ -31,12 +31,9 @@ from hydroqc.error import (
31
31
  from hydroqc.hydro_api.cache import CCached
32
32
  from hydroqc.hydro_api.consts import (
33
33
  ANNUAL_DATA_URL,
34
- AUTH_CALLBACK_URL,
35
- AUTH_URL,
36
- AUTHORIZE_URL,
34
+ AUTH_CLIENT_WEB,
35
+ AUTH_CLIENTS,
37
36
  AZB2C_CLIENT_ID_WEB,
38
- AZB2C_POLICY,
39
- AZB2C_SCOPE_WEB,
40
37
  AZB2C_TIMEOUT_SKEW_SECS,
41
38
  CONSO_CSV_URL,
42
39
  CONSO_OVERVIEW_CSV_URL,
@@ -60,7 +57,6 @@ from hydroqc.hydro_api.consts import (
60
57
  RELATION_URL,
61
58
  REQUESTS_TIMEOUT,
62
59
  SESSION_URL,
63
- TOKEN_URL,
64
60
  )
65
61
  from hydroqc.hydro_api.mfa import (
66
62
  B2CPage,
@@ -128,6 +124,7 @@ class HydroClient:
128
124
  cookie_jar: aiohttp.CookieJar | None = None,
129
125
  refresh_token: str = "",
130
126
  refresh_token_expiry: datetime | None = None,
127
+ auth_client: str = AUTH_CLIENT_WEB,
131
128
  ):
132
129
  """Initialize the client object.
133
130
 
@@ -153,8 +150,17 @@ class HydroClient:
153
150
  needed. Defaults to "".
154
151
  refresh_token_expiry: Expiry of ``refresh_token``. Defaults to None,
155
152
  which marks the session as already expired.
153
+ auth_client: B2C client to log in with, ``"web"`` (the Espace
154
+ client) or ``"mobile"`` (the Android app, whose refresh token
155
+ lasts 90 days). Defaults to ``"web"``.
156
+
157
+ Raises:
158
+ ValueError: ``auth_client`` is not a known client.
156
159
 
157
160
  """
161
+ if auth_client not in AUTH_CLIENTS:
162
+ raise ValueError(f"Unknown auth_client: {auth_client!r}")
163
+ self._auth = AUTH_CLIENTS[auth_client]
158
164
  self.username: str = username
159
165
  self.password: str = password
160
166
  self._timeout: int = timeout
@@ -482,10 +488,10 @@ class HydroClient:
482
488
  "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
483
489
  }
484
490
  params = {
485
- "redirect_uri": AUTH_CALLBACK_URL,
486
- "client_id": AZB2C_CLIENT_ID_WEB,
491
+ "redirect_uri": self._auth.redirect_uri,
492
+ "client_id": self._auth.client_id,
487
493
  "response_type": "code",
488
- "scope": AZB2C_SCOPE_WEB,
494
+ "scope": self._auth.scope,
489
495
  "prompt": prompt,
490
496
  "ui_locales": "fr",
491
497
  "code_challenge": code_challenge,
@@ -496,7 +502,11 @@ class HydroClient:
496
502
  # Allow redirects for the initial authorize call
497
503
  # (Azure B2C sometimes issues a 302 before the final HTML)
498
504
  res = await self.http_request(
499
- AUTHORIZE_URL, "get", headers=headers, params=params, allow_redirects=True
505
+ self._auth.authorize_url,
506
+ "get",
507
+ headers=headers,
508
+ params=params,
509
+ allow_redirects=True,
500
510
  )
501
511
  if res.status != 200:
502
512
  self._logger.error(
@@ -514,7 +524,7 @@ class HydroClient:
514
524
  ``signInName`` and ``password``, the ``x-csrf-token`` header set to the
515
525
  value extracted from the sign-in page and the session cookies.
516
526
  """
517
- url = AUTH_URL + "?tx=" + transid + "&p=" + AZB2C_POLICY
527
+ url = self._auth.auth_url + "?tx=" + transid + "&p=" + self._auth.policy
518
528
  headers = {
519
529
  "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
520
530
  "accept": "application/json, text/javascript, */*; q=0.01",
@@ -556,7 +566,7 @@ class HydroClient:
556
566
  ``SelfAsserted`` when the call follows the verification page.
557
567
  """
558
568
  url = (
559
- AUTH_URL.rsplit("/", 1)[0]
569
+ self._auth.auth_url.rsplit("/", 1)[0]
560
570
  + "/api/"
561
571
  + api
562
572
  + "/confirmed?csrf_token="
@@ -564,7 +574,7 @@ class HydroClient:
564
574
  + "&tx="
565
575
  + transid
566
576
  + "&p="
567
- + AZB2C_POLICY
577
+ + self._auth.policy
568
578
  )
569
579
  if api == "CombinedSigninAndSignup":
570
580
  url += "&rememberMe=false"
@@ -846,10 +856,10 @@ class HydroClient:
846
856
  "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
847
857
  }
848
858
  params = {
849
- "redirect_uri": AUTH_CALLBACK_URL,
850
- "client_id": AZB2C_CLIENT_ID_WEB,
859
+ "redirect_uri": self._auth.redirect_uri,
860
+ "client_id": self._auth.client_id,
851
861
  "response_type": "code",
852
- "scope": AZB2C_SCOPE_WEB,
862
+ "scope": self._auth.scope,
853
863
  "prompt": "none",
854
864
  "ui_locales": "fr",
855
865
  "code_challenge": code_challenge,
@@ -857,7 +867,7 @@ class HydroClient:
857
867
  "mobile": "false",
858
868
  }
859
869
  res = await self.http_request(
860
- AUTHORIZE_URL,
870
+ self._auth.authorize_url,
861
871
  "get",
862
872
  headers=headers,
863
873
  params=params,
@@ -878,13 +888,15 @@ class HydroClient:
878
888
  headers = {"content-type": "application/x-www-form-urlencoded", "accept": "*/*"}
879
889
  data = {
880
890
  "grant_type": "authorization_code",
881
- "client_id": AZB2C_CLIENT_ID_WEB,
882
- "redirect_uri": AUTH_CALLBACK_URL,
891
+ "client_id": self._auth.client_id,
892
+ "redirect_uri": self._auth.redirect_uri,
883
893
  "code": code,
884
894
  "code_verifier": self._code_verifier,
885
895
  }
886
896
 
887
- res = await self.http_request(TOKEN_URL, "post", headers=headers, data=data)
897
+ res = await self.http_request(
898
+ self._auth.token_url, "post", headers=headers, data=data
899
+ )
888
900
  payload = await self._json_or_empty(res)
889
901
  if not payload.get("access_token"):
890
902
  self._logger.error(
@@ -934,6 +946,7 @@ class HydroClient:
934
946
  sign-on cookie is still valid.
935
947
  """
936
948
  return {
949
+ "client_id": self._auth.client_id,
937
950
  "refresh_token": self.refresh_token,
938
951
  "refresh_token_expiry": self.refresh_token_expiry.isoformat(),
939
952
  "access_token": self.access_token,
@@ -946,7 +959,23 @@ class HydroClient:
946
959
  }
947
960
 
948
961
  def import_session_state(self, state: Mapping[str, Any]) -> None:
949
- """Restore a session produced by :meth:`export_session_state`."""
962
+ """Restore a session produced by :meth:`export_session_state`.
963
+
964
+ The tokens are restored only when the state records the current client
965
+ id. A state with no ``client_id`` predates this field and comes from
966
+ the web client. Tokens of another client cannot be refreshed here, so
967
+ they are dropped and the caller gets a plain interactive login. The
968
+ login host cookies are restored either way, as they belong to the host
969
+ and not to one client.
970
+ """
971
+ if state.get("client_id", AZB2C_CLIENT_ID_WEB) != self._auth.client_id:
972
+ self._logger.info(
973
+ "Ignoring the tokens of a stored session issued for another "
974
+ "B2C client (an interactive login is required)"
975
+ )
976
+ self._restore_session_cookies(state)
977
+ return
978
+
950
979
  refresh_token = state.get("refresh_token")
951
980
  if isinstance(refresh_token, str):
952
981
  self.refresh_token = refresh_token
@@ -963,6 +992,10 @@ class HydroClient:
963
992
  if isinstance(access_expiry, str):
964
993
  self.access_token_expiry = self._parse_datetime(access_expiry)
965
994
 
995
+ self._restore_session_cookies(state)
996
+
997
+ def _restore_session_cookies(self, state: Mapping[str, Any]) -> None:
998
+ """Restore the login host cookies of a stored session."""
966
999
  cookies = state.get("cookies")
967
1000
  if isinstance(cookies, list):
968
1001
  if self._cookie_jar is None:
@@ -989,15 +1022,15 @@ class HydroClient:
989
1022
  """Refresh current session."""
990
1023
  self._logger.debug("Refreshing access token")
991
1024
 
992
- url = TOKEN_URL
1025
+ url = self._auth.token_url
993
1026
  headers = {
994
1027
  "Content-Type": "application/x-www-form-urlencoded",
995
1028
  "Accept": "application/json, text/plain, */*",
996
1029
  }
997
1030
  data = {
998
1031
  "grant_type": "refresh_token",
999
- "scope": AZB2C_SCOPE_WEB,
1000
- "client_id": AZB2C_CLIENT_ID_WEB,
1032
+ "scope": self._auth.scope,
1033
+ "client_id": self._auth.client_id,
1001
1034
  "refresh_token": self.refresh_token,
1002
1035
  }
1003
1036
 
@@ -1113,7 +1146,9 @@ class HydroClient:
1113
1146
  "Content-Type": "application/json",
1114
1147
  "Authorization": "Bearer " + await self._get_access_token(),
1115
1148
  }
1116
- res = await self.http_request(RELATION_URL, "get", headers=headers)
1149
+ res = await self.http_request(
1150
+ self._auth.api_url(RELATION_URL), "get", headers=headers
1151
+ )
1117
1152
  # TODO http errors
1118
1153
  data: list[AccountTyping] = await res.json()
1119
1154
  return data
@@ -1127,7 +1162,7 @@ class HydroClient:
1127
1162
  headers = await self._get_customer_http_headers(applicant_id, customer_id)
1128
1163
  params = {"withCredentials": "true"}
1129
1164
  api_call_response = await self.http_request(
1130
- CUSTOMER_INFO_URL,
1165
+ self._auth.api_url(CUSTOMER_INFO_URL),
1131
1166
  "get",
1132
1167
  headers=headers,
1133
1168
  params=params,
@@ -1173,7 +1208,9 @@ class HydroClient:
1173
1208
  ) -> AccountContractSummaryTyping:
1174
1209
  """Get all account_contract linked to a customer."""
1175
1210
  headers = await self._get_customer_http_headers(applicant_id, customer_id)
1176
- res = await self.http_request(CONTRACT_SUMMARY_URL, "get", headers=headers)
1211
+ res = await self.http_request(
1212
+ self._auth.api_url(CONTRACT_SUMMARY_URL), "get", headers=headers
1213
+ )
1177
1214
  data: AccountContractSummaryTyping = await res.json()
1178
1215
  return data
1179
1216
 
@@ -1201,7 +1238,10 @@ class HydroClient:
1201
1238
  }
1202
1239
  post_data_str = json_dumps(post_data)
1203
1240
  res = await self.http_request(
1204
- CONTRACT_LIST_URL, "post", headers=headers, data=post_data_str
1241
+ self._auth.api_url(CONTRACT_LIST_URL),
1242
+ "post",
1243
+ headers=headers,
1244
+ data=post_data_str,
1205
1245
  )
1206
1246
  data: ListContractsTyping = await res.json()
1207
1247
  # We ask only one contract, so we should have only one
@@ -1221,7 +1261,7 @@ class HydroClient:
1221
1261
  headers = await self._get_customer_http_headers(applicant_id, customer_id)
1222
1262
  params = {"noContrat": contract_id}
1223
1263
  api_call_response = await self.http_request(
1224
- GET_CPC_API_URL,
1264
+ self._auth.api_url(GET_CPC_API_URL),
1225
1265
  "get",
1226
1266
  headers=headers,
1227
1267
  params=params,
@@ -1396,7 +1436,7 @@ class HydroClient:
1396
1436
  headers = await self._get_customer_http_headers(applicant_id, customer_id)
1397
1437
  params = {"noContrat": contract_id}
1398
1438
  api_call_response = await self.http_request(
1399
- FLEXD_DATA_URL, "get", params=params, headers=headers
1439
+ self._auth.api_url(FLEXD_DATA_URL), "get", params=params, headers=headers
1400
1440
  )
1401
1441
  # We can not use res.json() because the response header are not application/json
1402
1442
  data: DPCDataTyping = self._load_json(await api_call_response.text())
@@ -5,6 +5,8 @@
5
5
  avoid all the /portail/ URLs
6
6
  """
7
7
 
8
+ from dataclasses import dataclass
9
+
8
10
  # Always get the time using HydroQuebec Local Time
9
11
  REQUESTS_TIMEOUT = 30
10
12
  REQUESTS_TTL = 1
@@ -26,6 +28,11 @@ AZB2C_RESPONSE_TYPE = "code"
26
28
  AZB2C_SCOPE_WEB = (
27
29
  "openid https://connexionhq.onmicrosoft.com/hq-clientele/Espace.Client"
28
30
  )
31
+ AZB2C_POLICY_MOBILE = "B2C_1A_PRD_signup_signin_mobile"
32
+ AZB2C_SCOPE_MOBILE = (
33
+ "openid offline_access "
34
+ "https://connexionhq.onmicrosoft.com/hq-clientele-mobile/Espace.Client"
35
+ )
29
36
  AZB2C_CODE_CHALLENGE_METHOD = "S256"
30
37
 
31
38
  # Time to remove from the token expiration time to avoid calls to fail
@@ -39,6 +46,9 @@ AUTHORIZE_URL = (
39
46
  )
40
47
  AUTH_URL = f"{HOST_LOGIN}/{AZB2C_TENANT_ID}/{AZB2C_POLICY}/SelfAsserted"
41
48
  AUTH_CALLBACK_URL = f"{HOST_SESSION}/oauth2/callback"
49
+ AUTH_CALLBACK_URL_MOBILE = (
50
+ "msauth://com.hydroquebec.mf_android/2TD6UgHUYzHyQirztabBgWTrJNs%3D"
51
+ )
42
52
  TOKEN_URL = f"{HOST_LOGIN}/{AZB2C_TENANT_ID}/{AZB2C_POLICY.lower()}/oauth2/v2.0/token"
43
53
 
44
54
  CHECK_SESSION_URL = f"{HOST_LOGIN}/hqam/oauth2/connect/checkSession"
@@ -130,3 +140,59 @@ GET_CPC_API_URL = (
130
140
  )
131
141
  # IS PORTAL RUNNING
132
142
  IS_HYDRO_PORTAL_UP_URL = f"{HOST_SESSION}/portail/fr/group/clientele/gerer-mon-compte"
143
+
144
+
145
+ @dataclass(frozen=True)
146
+ class AuthClient:
147
+ """Azure B2C client used to log in, with the private API it can call."""
148
+
149
+ client_id: str
150
+ policy: str
151
+ scope: str
152
+ redirect_uri: str
153
+ # Path segment of the private API: /wsapi/<api_channel>/prive/...
154
+ api_channel: str
155
+
156
+ @property
157
+ def authorize_url(self) -> str:
158
+ """Return the authorize endpoint of the policy."""
159
+ return (
160
+ f"{HOST_LOGIN}/{AZB2C_TENANT_ID}/{self.policy.lower()}"
161
+ "/oauth2/v2.0/authorize"
162
+ )
163
+
164
+ @property
165
+ def auth_url(self) -> str:
166
+ """Return the SelfAsserted endpoint of the policy."""
167
+ return f"{HOST_LOGIN}/{AZB2C_TENANT_ID}/{self.policy}/SelfAsserted"
168
+
169
+ @property
170
+ def token_url(self) -> str:
171
+ """Return the token endpoint of the policy."""
172
+ return f"{HOST_LOGIN}/{AZB2C_TENANT_ID}/{self.policy.lower()}/oauth2/v2.0/token"
173
+
174
+ def api_url(self, url: str) -> str:
175
+ """Return a private API URL (declared on /wsapi/web/) for this client."""
176
+ return url.replace("/wsapi/web/", f"/wsapi/{self.api_channel}/", 1)
177
+
178
+
179
+ AUTH_CLIENT_WEB = "web"
180
+ AUTH_CLIENT_MOBILE = "mobile"
181
+ AUTH_CLIENTS = {
182
+ AUTH_CLIENT_WEB: AuthClient(
183
+ client_id=AZB2C_CLIENT_ID_WEB,
184
+ policy=AZB2C_POLICY,
185
+ scope=AZB2C_SCOPE_WEB,
186
+ redirect_uri=AUTH_CALLBACK_URL,
187
+ api_channel="web",
188
+ ),
189
+ # Client of the official Android app: offline_access gives it a 90-day
190
+ # sliding refresh token, so the e-mail code is not asked every day.
191
+ AUTH_CLIENT_MOBILE: AuthClient(
192
+ client_id=AZB2C_CLIENT_ID_MOBILE,
193
+ policy=AZB2C_POLICY_MOBILE,
194
+ scope=AZB2C_SCOPE_MOBILE,
195
+ redirect_uri=AUTH_CALLBACK_URL_MOBILE,
196
+ api_channel="mobile",
197
+ ),
198
+ }
hydroqc/webuser.py CHANGED
@@ -12,6 +12,7 @@ from hydroqc.consts import LoginStatus
12
12
  from hydroqc.customer import Customer
13
13
  from hydroqc.error import HydroQcError
14
14
  from hydroqc.hydro_api.client import HydroClient
15
+ from hydroqc.hydro_api.consts import AUTH_CLIENT_WEB
15
16
  from hydroqc.logger import get_logger
16
17
 
17
18
 
@@ -35,8 +36,13 @@ class WebUser:
35
36
  cookie_jar: aiohttp.CookieJar | None = None,
36
37
  refresh_token: str = "",
37
38
  refresh_token_expiry: datetime | None = None,
39
+ auth_client: str = AUTH_CLIENT_WEB,
38
40
  ):
39
- """Create a new Hydroquebec webuser."""
41
+ """Create a new Hydroquebec webuser.
42
+
43
+ ``auth_client`` selects the B2C client, ``"web"`` (default) or
44
+ ``"mobile"``, see :class:`HydroClient`.
45
+ """
40
46
  self._hydro_client = HydroClient(
41
47
  username,
42
48
  password,
@@ -47,6 +53,7 @@ class WebUser:
47
53
  cookie_jar=cookie_jar,
48
54
  refresh_token=refresh_token,
49
55
  refresh_token_expiry=refresh_token_expiry,
56
+ auth_client=auth_client,
50
57
  )
51
58
  self._username: str = username
52
59
  self._log_level: str | None = log_level