Skip to content

Commit a562ff6

Browse files
committed
fix: when trying to use an expired refresh token, throw a ManualLoginRequired exception, instead of throwing a random KeyNotFound exception
1 parent 4f11368 commit a562ff6

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

ws_api/wealthsimple_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def check_oauth_token(self, persist_session_fct: Optional[Callable[[WSAPISession
151151
'x-ws-profile': 'invest'
152152
}
153153
response = self.send_post(f"{self.OAUTH_BASE_URL}/token", data, headers)
154+
if not 'access_token' in response or not 'refresh_token' in response:
155+
raise ManualLoginRequired(f"OAuth token invalid and cannot be refreshed: {response['error'] if 'error' in response else 'Invalid response from API'}")
154156
self.session.access_token = response['access_token']
155157
self.session.refresh_token = response['refresh_token']
156158
if persist_session_fct:

0 commit comments

Comments
 (0)