mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-24 07:23:01 +08:00
🎨 #1381 企业微信模块配置类增加autoRefreshToken参数配置,方便控制是否自动刷新access_token
This commit is contained in:
parent
2e2d5ffb56
commit
8b280f4eb1
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user