-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
微信官方要求通讯录同步相关 API(成员/部门 CRUD)仅支持通过「通讯录同步 secret」获取的独立 access token 调用,现有实现未支持此场景 #4047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
3298814
0a9e488
a69e8f8
c4b6994
57a9da7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -313,6 +313,29 @@ public String postForMsgAudit(String url, String postData) throws WxErrorExcepti | |
| return this.executeNormal(SimplePostRequestExecutor.create(this), urlWithToken, postData); | ||
| } | ||
|
|
||
| @Override | ||
| public String getForContact(String url, String queryParam) throws WxErrorException { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 当前只新增了 Useful? React with 👍 / 👎. |
||
| // 获取通讯录同步专用的access token | ||
| String contactAccessToken = getContactAccessToken(false); | ||
| // 拼接access_token参数 | ||
| String urlWithToken = url + (url.contains("?") ? "&" : "?") + "access_token=" + contactAccessToken; | ||
| if (queryParam != null && !queryParam.isEmpty()) { | ||
| urlWithToken = urlWithToken + "&" + queryParam; | ||
| } | ||
| // 使用executeNormal方法,不自动添加token | ||
| return this.executeNormal(SimpleGetRequestExecutor.create(this), urlWithToken, null); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 当微信端提前判定缓存的通讯录 Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| @Override | ||
| public String postForContact(String url, String postData) throws WxErrorException { | ||
| // 获取通讯录同步专用的access token | ||
| String contactAccessToken = getContactAccessToken(false); | ||
| // 拼接access_token参数 | ||
| String urlWithToken = url + (url.contains("?") ? "&" : "?") + "access_token=" + contactAccessToken; | ||
| // 使用executeNormal方法,不自动添加token | ||
| return this.executeNormal(SimplePostRequestExecutor.create(this), urlWithToken, postData); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| /** | ||
| * 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求. | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里新增了通讯录专用请求入口,但我用
rg "getForContact|postForContact"检查到它们只在接口和 Base 实现中出现,现有WxCpUserServiceImpl和WxCpDepartmentServiceImpl仍然调用mainService.get/post(例如成员 create/list、部门 create/list)。因此用户按现有高层 API 调用成员/部门 CRUD 时,即使配置了contactSecret,请求仍会带普通应用access_token,在企业微信要求通讯录同步 secret 的环境下会继续失败;需要把这些通讯录相关服务切到getForContact/postForContact。Useful? React with 👍 / 👎.