mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-12 21:00:46 +08:00
v1.5.5 use rt and at
This commit is contained in:
parent
2388d437cc
commit
cdadb258bf
@ -59,6 +59,7 @@ else:
|
||||
with open(TOKENS_FILE, "w", encoding="utf-8") as f:
|
||||
pass
|
||||
|
||||
|
||||
if os.path.exists(ERROR_TOKENS_FILE):
|
||||
with open(ERROR_TOKENS_FILE, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
|
||||
@ -45,14 +45,14 @@ async def chat_refresh(refresh_token):
|
||||
access_token = r.json()['access_token']
|
||||
return access_token
|
||||
else:
|
||||
if "Unknown or invalid refresh token." in r.text:
|
||||
with open(globals.ERROR_TOKENS_FILE, "a", encoding="utf-8") as f:
|
||||
f.write(refresh_token + "\n")
|
||||
if "invalid_grant" in r.text or "access_denied" in r.text:
|
||||
if refresh_token not in globals.error_token_list:
|
||||
globals.error_token_list.append(refresh_token)
|
||||
with open(globals.ERROR_TOKENS_FILE, "a", encoding="utf-8") as f:
|
||||
f.write(refresh_token + "\n")
|
||||
raise Exception(r.text)
|
||||
else:
|
||||
raise Exception(r.text[:100])
|
||||
raise Exception(r.text[:300])
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to refresh access_token `{refresh_token}`: {str(e)}")
|
||||
raise HTTPException(status_code=500, detail=f"Failed to refresh access_token.")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user