@@ -281,7 +281,9 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | |||||
if (error.getErrorCode() == 42001 || error.getErrorCode() == 40001 || error.getErrorCode() == 40014) { | if (error.getErrorCode() == 42001 || error.getErrorCode() == 40001 || error.getErrorCode() == 40014) { | ||||
// 强制设置wxCpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token | // 强制设置wxCpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token | ||||
this.configStorage.expireAccessToken(); | this.configStorage.expireAccessToken(); | ||||
return execute(executor, uri, data); | |||||
if (this.getWxCpConfigStorage().autoRefreshToken()) { | |||||
return this.execute(executor, uri, data); | |||||
} | |||||
} | } | ||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
@@ -194,7 +194,9 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ | |||||
if (error.getErrorCode() == 42009) { | if (error.getErrorCode() == 42009) { | ||||
// 强制设置wxCpTpConfigStorage它的suite access token过期了,这样在下一次请求里就会刷新suite access token | // 强制设置wxCpTpConfigStorage它的suite access token过期了,这样在下一次请求里就会刷新suite access token | ||||
this.configStorage.expireSuiteAccessToken(); | this.configStorage.expireSuiteAccessToken(); | ||||
return execute(executor, uri, data); | |||||
if (this.getWxCpTpConfigStorage().autoRefreshToken()) { | |||||
return this.execute(executor, uri, data); | |||||
} | |||||
} | } | ||||
if (error.getErrorCode() != 0) { | if (error.getErrorCode() != 0) { | ||||
@@ -97,4 +97,10 @@ public interface WxCpConfigStorage { | |||||
* @return ApacheHttpClientBuilder | * @return ApacheHttpClientBuilder | ||||
*/ | */ | ||||
ApacheHttpClientBuilder getApacheHttpClientBuilder(); | ApacheHttpClientBuilder getApacheHttpClientBuilder(); | ||||
/** | |||||
* 是否自动刷新token | |||||
* @return . | |||||
*/ | |||||
boolean autoRefreshToken(); | |||||
} | } |
@@ -83,4 +83,10 @@ public interface WxCpTpConfigStorage { | |||||
* @return ApacheHttpClientBuilder | * @return ApacheHttpClientBuilder | ||||
*/ | */ | ||||
ApacheHttpClientBuilder getApacheHttpClientBuilder(); | ApacheHttpClientBuilder getApacheHttpClientBuilder(); | ||||
/** | |||||
* 是否自动刷新token | |||||
* @return . | |||||
*/ | |||||
boolean autoRefreshToken(); | |||||
} | } |
@@ -262,6 +262,11 @@ public class WxCpDefaultConfigImpl implements WxCpConfigStorage, Serializable { | |||||
return this.apacheHttpClientBuilder; | return this.apacheHttpClientBuilder; | ||||
} | } | ||||
@Override | |||||
public boolean autoRefreshToken() { | |||||
return true; | |||||
} | |||||
public void setApacheHttpClientBuilder(ApacheHttpClientBuilder apacheHttpClientBuilder) { | public void setApacheHttpClientBuilder(ApacheHttpClientBuilder apacheHttpClientBuilder) { | ||||
this.apacheHttpClientBuilder = apacheHttpClientBuilder; | this.apacheHttpClientBuilder = apacheHttpClientBuilder; | ||||
} | } | ||||
@@ -242,6 +242,11 @@ public class WxCpTpDefaultConfigImpl implements WxCpTpConfigStorage, Serializabl | |||||
return this.apacheHttpClientBuilder; | return this.apacheHttpClientBuilder; | ||||
} | } | ||||
@Override | |||||
public boolean autoRefreshToken() { | |||||
return true; | |||||
} | |||||
public void setApacheHttpClientBuilder(ApacheHttpClientBuilder apacheHttpClientBuilder) { | public void setApacheHttpClientBuilder(ApacheHttpClientBuilder apacheHttpClientBuilder) { | ||||
this.apacheHttpClientBuilder = apacheHttpClientBuilder; | this.apacheHttpClientBuilder = apacheHttpClientBuilder; | ||||
} | } | ||||