From 369f6fea54dc2a0692926bd3fdfb3126bb73ce06 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 25 May 2026 17:15:56 +0800 Subject: [PATCH] feat: add token() auth function for Vidu API Token authentication - Add token(apikey) function in appapi.py returning 'Token {apikey}' - Import and register token() in init.py ServerEnv - Supports Vidu API's Token auth scheme (vs existing Bearer/Deerer) --- uapi/appapi.py | 3 +++ uapi/init.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/uapi/appapi.py b/uapi/appapi.py index 57d671d..a42085d 100644 --- a/uapi/appapi.py +++ b/uapi/appapi.py @@ -115,6 +115,9 @@ def deerer(myappid, apikey, secretkey): def bearer(apikey): return f'Bearer {apikey}' +def token(apikey): + return f'Token {apikey}' + async def sync_users(request, upappid, userid): db = DBPools() dbname = get_dbname() diff --git a/uapi/init.py b/uapi/init.py index 04978ff..ba9deeb 100644 --- a/uapi/init.py +++ b/uapi/init.py @@ -4,8 +4,9 @@ from .appapi import ( deerer, sor_get_uapi_by_appname_apiname, bearer, + token, get_callerid, - sor_get_callerid, + sor_get_callerid, get_deerer ) from .uptask import ( @@ -28,6 +29,7 @@ def load_uapi(): g.sor_get_callerid = sor_get_callerid g.sor_get_uapi_by_appname_apiname = sor_get_uapi_by_appname_apiname g.bearer = bearer + g.token = token g.check_uptask_status = check_uptask_status g.get_my_uptasks = get_my_uptasks g.uptask_feedback = uptask_feedback @@ -43,6 +45,10 @@ def load_uapi(): ## in your header template ## {{bearer(apikey)}} +# token usage (for APIs that use Token auth, e.g. Vidu) +## in your header template +## {{token(apikey)}} + # deerer usge ## in your header template ## {{deerer(myappid, apikey, secretkey)}}