Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
bugfix. wrong tokens is stuck in cache for good. (#1484)
Browse files Browse the repository at this point in the history
* fix [BUG] #1407

* Update typings.py

remove duplicate import

* bugfix. wrong tokens is stuck in cache for good.

---------

Co-authored-by: vgdh <info@we4.ru>
  • Loading branch information
vgdh and vgdh committed Aug 2, 2023
1 parent 36d1c8f commit 54cea93
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/revChatGPT/V1.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,27 @@ def __get_cached_access_token(self, email: str | None) -> str | None:
d_access_token = base64.b64decode(s_access_token[1])
d_access_token = json.loads(d_access_token)
except binascii.Error:
del cache["access_tokens"][email]
self.__write_cache(cache)
error = t.Error(
source="__get_cached_access_token",
message="Invalid access token",
code=t.ErrorType.INVALID_ACCESS_TOKEN_ERROR,
)
del cache["access_tokens"][email]
raise error from None
except json.JSONDecodeError:
del cache["access_tokens"][email]
self.__write_cache(cache)
error = t.Error(
source="__get_cached_access_token",
message="Invalid access token",
code=t.ErrorType.INVALID_ACCESS_TOKEN_ERROR,
)
raise error from None
except IndexError:
del cache["access_tokens"][email]
self.__write_cache(cache)
error = t.Error(
source="__get_cached_access_token",
message="Invalid access token",
Expand Down

0 comments on commit 54cea93

Please sign in to comment.