Skip to content

Commit 551241e

Browse files
committed
fix: correctly catch "Not Authorized" error when initiating session, allowing the refresh token to be used to get a new access token
Fixes #63
1 parent c9e2b0e commit 551241e

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "ws-api"
7-
version = "0.33.1"
7+
version = "0.33.2"
88
description = "Access your Wealthsimple account using their (GraphQL) API."
99
readme = "README.md"
1010
license = {file = "LICENSE"}

ws_api/wealthsimple_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ def check_oauth_token(
176176
try:
177177
self.search_security("XEQT")
178178
except WSApiException as e:
179-
if e.response is None or e.response.get("message") != "Not Authorized.":
179+
is_not_authorized = e.response is not None and (e.response.get("message") == "Not Authorized." or ('errors' in e.response and e.response.get('errors')[0].get("message") == "Not Authorized."))
180+
if not is_not_authorized:
180181
raise
181182
# Access token expired; try to refresh it below
182183
else:

0 commit comments

Comments
 (0)