wechat icon indicating copy to clipboard operation
wechat copied to clipboard

[咨询]企业微信access_token应该是根据应用隔离的?

Open excxapp opened this issue 3 years ago • 4 comments

请描述您的问题 企业微信的access_token是应用隔离的。 但是看现在代码 ` // NewWork init work func NewWork(cfg *config.Config) *Work { defaultAkHandle := credential.NewWorkAccessToken(cfg.CorpID, cfg.CorpSecret, credential.CacheKeyWorkPrefix, cfg.Cache) ctx := &context.Context{ Config: cfg, AccessTokenHandle: defaultAkHandle, } return &Work{ctx: ctx} }

` 没有引入agent_id作为缓存可以,是不是会造成冲突

excxapp avatar Feb 24 '22 10:02 excxapp

改写下 credential.CacheKeyWorkPrefix的值,是否可以达到你说的这个目的?

silenceper avatar Feb 24 '22 14:02 silenceper

企业微信多个模块(功能都有单独的Secret)

Wlhet avatar Mar 01 '22 09:03 Wlhet

这个方案么

popstk avatar Apr 20 '23 09:04 popstk

改写下 credential.CacheKeyWorkPrefix的值,是否可以达到你说的这个目的?

accessToken 同企业下不同应用是不一样的 所以NewWorkAccessToken 需要默认 corpid + appid 隔离

我现在这样临时处理 client := work.NewWork(&workConfig.Config{ CorpID: corpId, CorpSecret: secret, AgentID: agentId, Cache: config.CacheImpl, }) // 需要按照应用隔离AccessToken client.GetContext().AccessTokenHandle = credential.NewWorkAccessToken(corpId, secret, credential.CacheKeyWorkPrefix+agentId+"_", config.CacheImpl)

wwek avatar Jan 09 '24 12:01 wwek