mirror of
https://github.com/Yanyutin753/RefreshToV1Api.git
synced 2025-10-15 07:31:35 +00:00
适配ninja
This commit is contained in:
8
main.py
8
main.py
@@ -2257,11 +2257,11 @@ def chat_completions():
|
|||||||
logger.info(f"从缓存读取到api_key.........。")
|
logger.info(f"从缓存读取到api_key.........。")
|
||||||
api_key = refresh_dict.get(api_key)
|
api_key = refresh_dict.get(api_key)
|
||||||
else:
|
else:
|
||||||
|
refresh_token = api_key
|
||||||
if REFRESH_TOACCESS_ENABLEOAI:
|
if REFRESH_TOACCESS_ENABLEOAI:
|
||||||
refresh_token = api_key
|
|
||||||
api_key = oaiGetAccessToken(api_key)
|
api_key = oaiGetAccessToken(api_key)
|
||||||
else:
|
else:
|
||||||
api_key = ninjaGetAccessToken(REFRESH_TOACCESS_NINJA_REFRESHTOACCESS_URL, api_key)
|
api_key = xyhelperGetAccessToken(REFRESH_TOACCESS_XYHELPER_REFRESHTOACCESS_URL, api_key)
|
||||||
if not api_key.startswith("eyJhb"):
|
if not api_key.startswith("eyJhb"):
|
||||||
return jsonify({"error": "refresh_token is wrong or refresh_token url is wrong!"}), 401
|
return jsonify({"error": "refresh_token is wrong or refresh_token url is wrong!"}), 401
|
||||||
add_to_dict(refresh_token, api_key)
|
add_to_dict(refresh_token, api_key)
|
||||||
@@ -2426,7 +2426,7 @@ def images_generations():
|
|||||||
refresh_token = api_key
|
refresh_token = api_key
|
||||||
api_key = oaiGetAccessToken(api_key)
|
api_key = oaiGetAccessToken(api_key)
|
||||||
else:
|
else:
|
||||||
api_key = ninjaGetAccessToken(REFRESH_TOACCESS_NINJA_REFRESHTOACCESS_URL, api_key)
|
api_key = xyhelperGetAccessToken(REFRESH_TOACCESS_XYHELPER_REFRESHTOACCESS_URL, api_key)
|
||||||
if not api_key.startswith("eyJhb"):
|
if not api_key.startswith("eyJhb"):
|
||||||
return jsonify({"error": "refresh_token is wrong or refresh_token url is wrong!"}), 401
|
return jsonify({"error": "refresh_token is wrong or refresh_token url is wrong!"}), 401
|
||||||
add_to_dict(refresh_token, api_key)
|
add_to_dict(refresh_token, api_key)
|
||||||
@@ -2606,7 +2606,7 @@ def updateRefresh_dict():
|
|||||||
refresh_token = key
|
refresh_token = key
|
||||||
access_token = oaiGetAccessToken(key)
|
access_token = oaiGetAccessToken(key)
|
||||||
else:
|
else:
|
||||||
access_token = ninjaGetAccessToken(REFRESH_TOACCESS_NINJA_REFRESHTOACCESS_URL, key)
|
access_token = xyhelperGetAccessToken(REFRESH_TOACCESS_XYHELPER_REFRESHTOACCESS_URL, key)
|
||||||
if not access_token.startswith("eyJhb"):
|
if not access_token.startswith("eyJhb"):
|
||||||
logger.debug("refresh_token is wrong or refresh_token url is wrong!")
|
logger.debug("refresh_token is wrong or refresh_token url is wrong!")
|
||||||
error_num += 1
|
error_num += 1
|
||||||
|
Reference in New Issue
Block a user