Skip to content

Commit 9de764b

Browse files
committed
if token renewal, fails return original 401
Before this change, for instance, deleting an API key would make the call return 404 instead.
1 parent 70ad65c commit 9de764b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

finegrain/src/finegrain/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,14 @@ async def _q() -> httpx.Response:
518518
if r.status_code == 401:
519519
self.logger.debug("renewing token")
520520
self.token = None
521-
await self.login()
522-
r = await _q()
521+
login_ok = False
522+
try:
523+
await self.login()
524+
login_ok = True
525+
except httpx.HTTPStatusError as e:
526+
self.logger.debug(f"login failed while renewing: {e}")
527+
if login_ok:
528+
r = await _q()
523529

524530
if raise_for_status:
525531
check_status(r)

0 commit comments

Comments
 (0)