Skip to content

微信服务号的access_token刷新机制 #738

Answered by messense
Liuxw17 asked this question in Q&A
Discussion options

You must be logged in to vote

if "errcode" in result and result["errcode"] != 0:
errcode = result["errcode"]
errmsg = result.get("errmsg", errcode)
if self.auto_retry and errcode in (
WeChatErrorCode.INVALID_CREDENTIAL.value,
WeChatErrorCode.INVALID_ACCESS_TOKEN.value,
WeChatErrorCode.EXPIRED_ACCESS_TOKEN.value,
):
logger.info("Access token expired, fetch a new one and retry request")
self.fetch_access_token()
access_token = self.session.get(self.access_token_key)
kwargs["params"]["access_token"] = access_token
return self._request(method=method, url_or_endpoint=url, result_processor=res…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by messense
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #737 on June 21, 2022 04:40.