1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-08 06:32:27 +08:00

officeaccount 和 miniprogram 添加UseStableAK 配置项

This commit is contained in:
CyJay
2024-08-06 17:30:31 +08:00
parent 05ac7148d4
commit 923b7df3a8
4 changed files with 16 additions and 2 deletions

View File

@@ -34,7 +34,13 @@ type MiniProgram struct {
// NewMiniProgram 实例化小程序 API
func NewMiniProgram(cfg *config.Config) *MiniProgram {
defaultAkHandle := credential.NewDefaultAccessToken(cfg.AppID, cfg.AppSecret, credential.CacheKeyMiniProgramPrefix, cfg.Cache)
var defaultAkHandle credential.AccessTokenContextHandle
const cacheKeyPrefix = credential.CacheKeyMiniProgramPrefix
if cfg.UseStableAK {
defaultAkHandle = credential.NewStableAccessToken(cfg.AppID, cfg.AppSecret, cacheKeyPrefix, cfg.Cache)
} else {
defaultAkHandle = credential.NewDefaultAccessToken(cfg.AppID, cfg.AppSecret, cacheKeyPrefix, cfg.Cache)
}
ctx := &context.Context{
Config: cfg,
AccessTokenHandle: defaultAkHandle,