1
0
mirror of synced 2025-12-23 18:48:00 +08:00

🎨 #1450 企业微信优化获取三方授权码的接口实现

* 重新实现企业微信三方授权,获取永久授权码返回信息

* 1、增加获取服务商三方预授权URL
2、修复授权后应用图标字段为空的bug

Co-authored-by: 袁启勋 <xun.yuan@infoship.cn>
This commit is contained in:
yuanqixun
2020-03-19 09:24:08 +08:00
committed by GitHub
parent 868545cfc3
commit 6f7bc7c02c
6 changed files with 367 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.WxCpTpService;
import me.chanjar.weixin.cp.bean.WxCpTpCorp;
import me.chanjar.weixin.cp.bean.WxCpTpPermanentCodeInfo;
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
@@ -128,6 +129,71 @@ public class BaseWxCpTpServiceImplTest {
final WxCpTpCorp tpCorp = tpService.getPermanentCode(authCode);
assertThat(tpCorp.getPermanentCode()).isEqualTo("xxxx");
final WxCpTpPermanentCodeInfo tpPermanentCodeInfo = tpService.getPermanentCodeInfo(authCode);
assertThat(tpPermanentCodeInfo.getAuthInfo().getAgent().get(0).getAgentid()).isEqualTo(1);
}
@Test
public void testGetPermanentCodeInfo() throws WxErrorException{
String returnJson = "{\n" +
" \"access_token\": \"u6SoEWyrEmworJ1uNzddbiXh42mCLNU_mdd6b01Afo2LKmyi-WdaaYqhEGFZjB1RGZ-rhjLcAJ86ger7b7Q0gowSw9iIDR8dm49aVH_MztzmQttP3XFG7np1Dxs_VQkVwhhRmfRpEonAmK1_JWIFqayJXXiPUS3LsFd3tWpE7rxmsRa7Ev2ml2htbRp_qGUjtFTErKoDsnNGSka6_RqFPA\", \n" +
" \"expires_in\": 7200, \n" +
" \"permanent_code\": \"lMLlxss77ntxzuEl1i1_AQ3-6-cvqMLYs209YNWVruk\", \n" +
" \"auth_corp_info\": {\n" +
" \"corpid\": \"xxxcorpid\", \n" +
" \"corp_name\": \"xxxx有限公司\", \n" +
" \"corp_type\": \"unverified\", \n" +
" \"corp_round_logo_url\": \"http://p.qpic.cn/pic_wework/3777001839/4046834be7a5f2711feaaa3cc4e691e1bcb1e526cb4544b5/0\", \n" +
" \"corp_square_logo_url\": \"https://p.qlogo.cn/bizmail/EsvsszIt9hJrjrx8QKXuIs0iczdnV4icaPibLIViaukn1iazCay8L1UXtibA/0\", \n" +
" \"corp_user_max\": 200, \n" +
" \"corp_agent_max\": 300, \n" +
" \"corp_wxqrcode\": \"http://p.qpic.cn/pic_wework/211781738/a9af41a60af7519775dd7ac846a4942979dc4a14b8bb2c72/0\", \n" +
" \"corp_full_name\": \"xxxx有限公司\", \n" +
" \"subject_type\": 1, \n" +
" \"corp_scale\": \"1-50人\", \n" +
" \"corp_industry\": \"生活服务\", \n" +
" \"corp_sub_industry\": \"租赁和商务服务\", \n" +
" \"location\": \"北京市\"\n" +
" }, \n" +
" \"auth_info\": {\n" +
" \"agent\": [\n" +
" {\n" +
" \"agentid\": 1000012, \n" +
" \"name\": \"xxxxx\", \n" +
" \"square_logo_url\": \"http://wx.qlogo.cn/mmhead/Q3auHgzwzM4ZCtdxicN8ghMOtTv7M7rLPKmeZ3amic00btdwbNmicaW3Q/0\", \n" +
" \"privilege\": {\n" +
" \"level\": 1, \n" +
" \"allow_party\": [ ], \n" +
" \"allow_user\": [\n" +
" \"yuanqixun\"\n" +
" ], \n" +
" \"allow_tag\": [ ], \n" +
" \"extra_party\": [ ], \n" +
" \"extra_user\": [ ], \n" +
" \"extra_tag\": [ ]\n" +
" }\n" +
" }\n" +
" ]\n" +
" }, \n" +
" \"auth_user_info\": {\n" +
" \"userid\": \"yuanqixun\", \n" +
" \"name\": \"袁启勋\", \n" +
" \"avatar\": \"http://wework.qpic.cn/bizmail/ZYqy8EswiaFyPnk7gy7eiafoicz3TL35f4bAvCf2eSe6RVYSK7aPDFxcw/0\"\n" +
" }\n" +
"}";
final WxCpTpConfigStorage configStorage = new WxCpTpDefaultConfigImpl();
tpService.setWxCpTpConfigStorage(configStorage);
JsonObject jsonObject = new JsonObject();
String authCode = "";
jsonObject.addProperty("auth_code", authCode);
doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString());
final WxCpTpPermanentCodeInfo tpPermanentCodeInfo = tpService.getPermanentCodeInfo(authCode);
assertThat(tpPermanentCodeInfo.getAuthInfo().getAgent().get(0).getAgentid()).isEqualTo(1000012);
assertNotNull(tpPermanentCodeInfo.getAuthInfo().getAgent().get(0).getSquareLogoUrl());
assertNotNull(tpPermanentCodeInfo.getAuthCorpInfo().getCorpSquareLogoUrl());
}
@Test