feat: 支持使用永久令牌进行认证

This commit is contained in:
Akimio521
2025-01-25 22:31:53 +08:00
parent 3bf27f224c
commit 8aed2b334e

View File

@@ -70,10 +70,13 @@ class Alist(StorageBase, metaclass=Singleton):
@cached(maxsize=1, ttl=60 * 60 * 24 * 2 - 60 * 5)
def __generate_token(self) -> str:
"""
使用账号密码生成一个临时token
如果设置永久令牌则返回永久令牌,否则使用账号密码生成一个临时 token
缓存2天提前5分钟更新
"""
conf = self.get_conf()
token = conf.get("token")
if token:
return str(token)
resp: Response = RequestUtils(headers={
'Content-Type': 'application/json'
}).post_res(