MCPcopy
hub / github.com/wechatpy/wechatpy / fetch_access_token

Method fetch_access_token

wechatpy/client/__init__.py:114–136  ·  view source on GitHub ↗

获取 access token 详情请参考 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list\ &t=resource/res_list&verify=1&id=open1419318587&token=&lang=zh_CN 这是内部刷新机制。请不要完全依赖! 因为有可能在缓存期间没有对此公众号的操作,造成refresh_token失效。 :return: 返回的 JSON 数据包

(self)

Source from the content-addressed store, hash-verified

112 return self.session.get(self.refresh_token_key)
113
114 def fetch_access_token(self):
115 """
116 获取 access token
117 详情请参考 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list\
118 &t=resource/res_list&verify=1&id=open1419318587&token=&lang=zh_CN
119
120 这是内部刷新机制。请不要完全依赖!
121 因为有可能在缓存期间没有对此公众号的操作,造成refresh_token失效。
122
123 :return: 返回的 JSON 数据包
124 """
125 expires_in = 7200
126 result = self.component.refresh_authorizer_token(
127 self.appid, self.refresh_token)
128 if 'expires_in' in result:
129 expires_in = result['expires_in']
130 self.session.set(
131 self.access_token_key,
132 result['authorizer_access_token'],
133 expires_in
134 )
135 self.expires_at = int(time.time()) + expires_in
136 return result

Callers 1

access_tokenMethod · 0.95

Calls 2

setMethod · 0.45

Tested by

no test coverage detected