-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
企业微信关于不同功能的 secret 使用问题 #2753
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
我这边的做法是:不用自带的starter,而是自己写一个WxCpConfiguration类,提供一个静态方法获取WxCpService,为了避免频繁创建WxCpService造成不必要的资源消耗,可以实现一个简单的ObjectPool用来缓存已经创建过的WxCpService对象,这样就可以实现在一个项目中使用多种类型的企业微信secret @Configuration
public class WxCpConfiguration {
private static RedissonClient redissonClient;
private static final ConcurrentHashMap<String, WxCpService> wxCpServicePool = new ConcurrentHashMap<>();
@Autowired
public WxCpConfiguration(RedissonClient redissonClient) {
WxCpConfiguration.redissonClient = redissonClient;
}
public static WxCpService getWxCpService(String corpid, String secret) {
return getWxCpService(corpid, secret, null);
}
public static WxCpService getWxCpService(String corpid, String secret, Integer agentId) {
String key = corpid + secret;
WxCpService wxCpService = wxCpServicePool.get(key);
if (wxCpService == null) {
wxCpService = new WxCpServiceImpl();
WxCpRedissonConfigImpl config = new WxCpRedissonConfigImpl(redissonClient, RedisConstants.GLOBAL_KEY_PREFIX + "wxWork:");
config.setCorpId(corpid);
config.setCorpSecret(secret);
config.setAgentId(agentId);
wxCpService.setWxCpConfigStorage(config);
wxCpServicePool.put(key, wxCpService);
}
return wxCpService;
}
} |
@yiyingcanfeng 目前也是通过创建多个 wxCpService 实现,非常感谢 |
getWxCpService 这个方法每次怎么用啊 |
可以参考该实现:#3149 |
Hi
你好这是一封自动回复邮件,现在是10.1嗨皮七天乐的时间,稍后我会马上回复你的邮件的
|
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
简要描述
企业微信官方给出了四种 secret 的解释,个人理解这四种 secret 分别是不同的权限的代表,但是目前提供的 wx-java-cp-spring-boot-starter 只能设置一种 secret,这块是不是需要创建多个 WxCpService 来处理不同的数据才好?
官方文档地址
请提供所需功能对应的微信官方文档地址以便进行确认。
secret
secret是企业应用里面用于保障数据安全的“钥匙”,每一个应用都有一个独立的访问密钥,为了保证数据的安全,secret务必不能泄漏。
目前secret有:
自建应用secret。在管理后台->“应用与小程序”->“应用”->“自建”,点进某个应用,即可看到。


基础应用secret。某些基础应用(如“审批”“打卡”应用),支持通过API进行操作。在管理后台->“应用与小程序”->“应用->”“基础”,点进某个应用,点开“API”小按钮,即可看到。
通讯录管理secret。在“管理工具”-“通讯录同步”里面查看(需开启“API接口同步”);
外部联系人管理secret。在“客户联系”栏,点开“API”小按钮,即可看到。
https://developer.work.weixin.qq.com/document/path/90665
The text was updated successfully, but these errors were encountered: