小程序登录
All checks were successful
Deploy to Server / deploy (push) Successful in 26s

This commit is contained in:
jeremygan2021
2026-02-27 16:33:26 +08:00
parent 53bf74893b
commit 4f4cfcd6f4
3 changed files with 66 additions and 18 deletions

View File

@@ -45,7 +45,7 @@ def get_current_wechat_user(request):
except (BadSignature, SignatureExpired):
return None
def get_access_token(config=None):
def get_access_token(config=None, force_refresh=False):
"""
获取微信接口调用凭证 (client_credential)
"""
@@ -54,9 +54,10 @@ def get_access_token(config=None):
if config:
cache_key = f'wechat_access_token_{config.app_id}'
token = cache.get(cache_key)
if token:
return token
if not force_refresh:
token = cache.get(cache_key)
if token:
return token
if not config:
# 优先查找指定 AppID