1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 12:52:27 +08:00
Files
wechat/work/config/config.go
mahongran 71c8ab58fb F ix work access token (#810)
* feat: enhance WorkAccessToken to include AgentID for improved token management

- Added AgentID field to WorkAccessToken struct.
- Updated NewWorkAccessToken function to accept AgentID as a parameter.
- Modified access token cache key to incorporate AgentID, ensuring unique cache entries per agent.

This change improves the handling of access tokens in a multi-agent environment.

* refactor: enhance WorkAccessToken to improve cache key handling

- Updated the AgentID field in WorkAccessToken struct to clarify its optional nature for distinguishing applications.
- Modified the access token cache key construction to support both new and legacy formats based on the presence of AgentID.
- Added comments for better understanding of the cache key logic and its compatibility with historical versions.

This change improves the flexibility and clarity of access token management in multi-agent scenarios.

* feat: enhance WorkAccessToken with new constructor for AgentID support

- Introduced NewWorkAccessTokenWithAgentID function to maintain backward compatibility while allowing for AgentID usage.
- Updated NewWorkAccessToken to call the new constructor, ensuring seamless integration.
- Improved error handling in GetAccessTokenContext by checking for cache availability and handling potential errors during cache operations.

This change enhances the flexibility of access token management, particularly in multi-agent scenarios, while ensuring compatibility with existing implementations.
2025-01-07 22:19:21 +08:00

18 lines
935 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package config 企业微信config配置
package config
import (
"github.com/silenceper/wechat/v2/cache"
)
// Config for 企业微信
type Config struct {
CorpID string `json:"corp_id"` // corp_id
CorpSecret string `json:"corp_secret"` // corp_secret,如果需要获取会话存档实例当前参数请填写聊天内容存档的Secret可以在企业微信管理端--管理工具--聊天内容存档查看
AgentID string `json:"agent_id"` // agent_id
Cache cache.Cache
RasPrivateKey string // 消息加密私钥,可以在企业微信管理端--管理工具--消息加密公钥查看对用公钥,私钥一般由自己保存
Token string `json:"token"` // 微信客服回调配置,用于生成签名校验回调请求的合法性
EncodingAESKey string `json:"encoding_aes_key"` // 微信客服回调p配置用于解密回调消息内容对应的密文
}