🐛 #1109 修复企业微信第三方应用获取永久授权码解析代码错误的问题
This commit is contained in:
@@ -15,7 +15,6 @@ import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
|
||||
* @author zhenjun cai
|
||||
*/
|
||||
public interface WxCpTpService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 验证推送过来的消息的正确性
|
||||
@@ -84,15 +83,15 @@ public interface WxCpTpService {
|
||||
WxAccessToken getCorpToken(String authCorpid, String permanentCode) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取企业永久授权码
|
||||
* 获取企业永久授权码 .
|
||||
*
|
||||
* @param authCode
|
||||
* @return
|
||||
* @param authCode .
|
||||
* @return .
|
||||
*/
|
||||
WxCpTpCorp getPermanentCode(String authCode) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求.
|
||||
*
|
||||
* @param url 接口地址
|
||||
* @param queryParam 请求参数
|
||||
@@ -100,7 +99,7 @@ public interface WxCpTpService {
|
||||
String get(String url, String queryParam) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
|
||||
*
|
||||
* @param url 接口地址
|
||||
* @param postData 请求body字符串
|
||||
@@ -124,7 +123,7 @@ public interface WxCpTpService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
|
||||
* 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试.
|
||||
* 默认:1000ms
|
||||
* </pre>
|
||||
*
|
||||
@@ -134,7 +133,7 @@ public interface WxCpTpService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 设置当微信系统响应系统繁忙时,最大重试次数
|
||||
* 设置当微信系统响应系统繁忙时,最大重试次数.
|
||||
* 默认:5次
|
||||
* </pre>
|
||||
*
|
||||
@@ -148,21 +147,21 @@ public interface WxCpTpService {
|
||||
void initHttp();
|
||||
|
||||
/**
|
||||
* 获取WxMpConfigStorage 对象
|
||||
* 获取WxMpConfigStorage 对象.
|
||||
*
|
||||
* @return WxMpConfigStorage
|
||||
*/
|
||||
WxCpTpConfigStorage getWxCpTpConfigStorage();
|
||||
|
||||
/**
|
||||
* 注入 {@link WxCpTpConfigStorage} 的实现
|
||||
* 注入 {@link WxCpTpConfigStorage} 的实现.
|
||||
*
|
||||
* @param wxConfigProvider 配置对象
|
||||
*/
|
||||
void setWxCpTpConfigStorage(WxCpTpConfigStorage wxConfigProvider);
|
||||
|
||||
/**
|
||||
* http请求对象
|
||||
* http请求对象.
|
||||
*/
|
||||
RequestHttp<?, ?> getRequestHttp();
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.*;
|
||||
|
||||
/**
|
||||
* .
|
||||
*
|
||||
@@ -95,7 +97,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
params.put("js_code", jsCode);
|
||||
params.put("grant_type", "authorization_code");
|
||||
|
||||
final String url = configStorage.getApiUrl(WxCpApiPathConsts.Tp.JSCODE_TO_SESSION);
|
||||
final String url = configStorage.getApiUrl(JSCODE_TO_SESSION);
|
||||
return WxCpMaJsCode2SessionResult.fromJson(this.get(url, Joiner.on("&").withKeyValueSeparator("=").join(params)));
|
||||
}
|
||||
|
||||
@@ -105,20 +107,19 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("auth_corpid", authCorpid);
|
||||
jsonObject.addProperty("permanent_code", permanentCode);
|
||||
String result = post(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_CORP_TOKEN), jsonObject.toString());
|
||||
String result = post(configStorage.getApiUrl(GET_CORP_TOKEN), jsonObject.toString());
|
||||
|
||||
return WxAccessToken.fromJson(result);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WxCpTpCorp getPermanentCode(String authCode) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("auth_code", authCode);
|
||||
|
||||
String result = post(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_PERMANENT_CODE), jsonObject.toString());
|
||||
String result = post(configStorage.getApiUrl(GET_PERMANENT_CODE), jsonObject.toString());
|
||||
jsonObject = new JsonParser().parse(result).getAsJsonObject();
|
||||
WxCpTpCorp wxCpTpCorp = WxCpTpCorp.fromJson(jsonObject.get("auth_corp_info").getAsString());
|
||||
WxCpTpCorp wxCpTpCorp = WxCpTpCorp.fromJson(jsonObject.get("auth_corp_info").getAsJsonObject().toString());
|
||||
wxCpTpCorp.setPermanentCode(jsonObject.get("permanent_code").getAsString());
|
||||
return wxCpTpCorp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user