Ver a proveniência

🎨 #1554 优化小程序获取token逻辑,减少刷新请求次数

dev1
Binary Wang há 5 anos
ascendente
cometimento
b87ec9a574
1 ficheiros alterados com 4 adições e 0 eliminações
  1. +4
    -0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java

+ 4
- 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java Ver ficheiro

@@ -116,6 +116,10 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
Lock lock = this.getWxMaConfig().getAccessTokenLock();
lock.lock();
try {
if (!this.getWxMaConfig().isAccessTokenExpired() && !forceRefresh) {
return this.getWxMaConfig().getAccessToken();
}
String url = String.format(WxMaService.GET_ACCESS_TOKEN_URL, this.getWxMaConfig().getAppid(),
this.getWxMaConfig().getSecret());
try {


Carregando…
Cancelar
Guardar