详细请教一下 AccessToken 过期失效的问题!

企业微信 文章 2021-04-01 10:41 1153 0 全屏看文

AI助手支持GPT4.0

详细请教一下 AccessToken 过期失效的问题!Please tell me more about the expiration of AccessToken!

详细请教一下 AccessToken 过期失效的问题!


请问一下:获取AccessToken以后,是从获取时间开始起,7200秒过期吗?

7200秒之内,获取的 AccessToken 值都是一样的。

还是从他变化值开始周期过期时间?


如果是这样自获取时间起,我就计算好时间即可6800秒更新一次 AccessToken。











获取AccessToken

AccessToken是企业号的全局唯一票据,调用接口时需携带AccessToken。

AccessToken需要用CorpIDSecret来换取,不同的Secret会返回不同的AccessToken。正常情况下AccessToken有效期为7200秒,有效期内重复获取返回相同结果。access_token至少保留512字节的存储空间。企业号可能会出于运营需要,提前使accesstoken失效,企业开发者也应实现accesstoken失效时重试获取的逻辑。

  • 请求说明

Https请求方式: GET

https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=id&corpsecret=secrect

  • 参数说明

参数必须说明corpid是企业Idcorpsecret是管理组的凭证密钥

Excuse me: after obtaining the accesstoken, does it expire in 7200 seconds from the acquisition time? Within 7200 seconds, the accesstoken values obtained are the same. Or does it start from its change value and cycle expiration time? If this is the case, I will calculate the time from the acquisition time, that is, I can update the accesstoken every 6800 seconds. Get accesstoken. Accesstoken is the globally unique bill of the enterprise number. You need to carry the accesstoken when calling the interface. Accesstoken needs to be exchanged with Corpid and secret. Different secrets will return different accesstoken. Under normal circumstances, the validity period of accesstoken is 7200 seconds, and the same result is returned by repeated acquisition within the validity period. access_ The token reserves at least 512 bytes of storage space. The enterprise number may make the accesstoken invalid in advance for operational needs, and the enterprise developers should also implement the logic of retrial when the accesstoken fails. Request description HTTP request method: get https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=id&corpsecret=secrect Parameter description the parameter must specify that Corpid is the enterprise, and idcorpsecret is the certificate key of the management group

回答:

崔直宏:

https://developers.weixin.qq.com/community/develop/article/doc/000e42bdab83c0cbd95b1556656013

可以看一下我总结的access_token使用方法,顺便附带了源码。我的方式是不刻意关心多久过期,而是主要关心调用业务接口失败时更新access_token,并重新调用业务接口。

青寒:

如果是这样自获取时间起,我就计算好时间即可6800秒更新一次 AccessToken。

可以。

天子:

我缓存的 AccessToken 在使用之前,有没有什么办法,能验证一下,它是否已过期呢?


MORNINGSTART:wx.checkSession  检查登录态是否过期

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
在主域里使用了async 库,使用微信开放数据域子域后,打包报错。
同一个小程序无跳转打开另一个小程序如何做到?
企业微信关联小程序,怎么清理StorageSyn的缓存?
关于字节跳动小程序使用微信h5支付 然后报关问题
开发者工具上传预览时提示:Error:无效的json文件:error:invalid file:
随便看看
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8062
问题? 7288
如何快速搭建抽奖助手小程序(无需代码知识) 5071
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 6026
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5639
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5231
如何解决渲染层网络错误Failed to load media? 16581
小程序找号找回 释放昵称? 2438
我的小程序广告主收入5301,实际进账4406,是怎么回事呀? 2519
删除部分微信用户个人数据的通知,怎么删除? 5568