{"record":{"id":"1a8fc0fd879405af","repo":"binarywang/WxJava","slug":"error-1a8fc0","errorCode":null,"errorMessage":"错误代码：{}, 错误信息：{}","messagePattern":"错误代码：(.+?), 错误信息：(.+?)","errorType":"exception","errorClass":"WxErrorException","httpStatus":null,"severity":"critical","filePath":"weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java","lineNumber":72,"sourceCode":"    synchronized (this.globalSuiteAccessTokenRefreshLock) {\n      try {\n        HttpPost httpPost = new HttpPost(configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_SUITE_TOKEN));\n        if (this.httpProxy != null) {\n          RequestConfig config = RequestConfig.custom()\n            .setProxy(this.httpProxy).build();\n          httpPost.setConfig(config);\n        }\n        JsonObject jsonObject = new JsonObject();\n        jsonObject.addProperty(\"suite_id\", this.configStorage.getSuiteId());\n        jsonObject.addProperty(\"suite_secret\", this.configStorage.getSuiteSecret());\n        jsonObject.addProperty(\"suite_ticket\", this.getSuiteTicket());\n        StringEntity entity = new StringEntity(jsonObject.toString(), StandardCharsets.UTF_8);\n        httpPost.setEntity(entity);\n\n        String resultContent = getRequestHttpClient().execute(httpPost, ApacheBasicResponseHandler.INSTANCE);\n        WxError error = WxError.fromJson(resultContent, WxType.CP);\n        if (error.getErrorCode() != 0) {\n          throw new WxErrorException(error);\n        }\n        jsonObject = GsonParser.parse(resultContent);\n        String suiteAccussToken = jsonObject.get(\"suite_access_token\").getAsString();\n        int expiresIn = jsonObject.get(\"expires_in\").getAsInt();\n        this.configStorage.updateSuiteAccessToken(suiteAccussToken, expiresIn);\n      } catch (IOException e) {\n        throw new WxRuntimeException(e);\n      }\n    }\n    return this.configStorage.getSuiteAccessToken();\n  }\n\n  @Override\n  public void initHttp() {\n    ApacheHttpClientBuilder apacheHttpClientBuilder = this.configStorage.getApacheHttpClientBuilder();\n    if (null == apacheHttpClientBuilder) {\n      apacheHttpClientBuilder = DefaultApacheHttpClientBuilder.get();\n    }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceApacheHttpClientImpl.java#L54-L90","documentation":"Thrown as WxErrorException when the Apache HttpClient implementation of getSuiteAccessToken() receives a non-zero error code from the suite_access_token endpoint (GET_SUITE_TOKEN). The request posts suite_id, suite_secret, and suite_ticket to WeChat; a non-zero response means the token could not be issued. The message format derives from WxError.toString().","triggerScenarios":"Suite access token request fails with errcode != 0: invalid suite_secret (640001), missing or expired suite_ticket (40029), invalid suite_id (40098), or IP whitelist violation (60020).","commonSituations":"suite_secret does not match the TP console; suite_ticket not being received (WeChat pushes every 10 min, 2-hour validity); server IP not whitelisted; suite disabled or under review.","solutions":["Verify suite_id and suite_secret exactly match the Third-Party Platform console settings","Ensure suite_ticket is being received via the callback URL and stored — it expires after 2 hours","Whitelist your server's public IP in the WeChat TP admin console under IP白名单","Inspect the WxError errorCode: 40029 = invalid suite_ticket, 640001 = invalid suite_secret, 60020 = IP not allowed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify suite credentials before relying on token auto-refresh\nif (StringUtils.isBlank(configStorage.getSuiteId())\n    || StringUtils.isBlank(configStorage.getSuiteSecret())) {\n  throw new IllegalStateException(\"suite_id and suite_secret must be configured\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  service.getSuiteAccessToken();\n} catch (WxErrorException e) {\n  WxError error = e.getError();\n  if (error.getErrorCode() == 40029) {\n    log.error(\"suite_ticket expired or missing — verify the callback endpoint\");\n  } else if (error.getErrorCode() == 60020) {\n    log.error(\"Server IP not whitelisted in WeChat TP console\");\n  }\n  throw e;\n}","preventionTips":["Verify suite_id and suite_secret match the TP console before deployment","Ensure the suite_ticket callback endpoint is functioning and stores tickets promptly","Whitelist your server's public IP in the TP admin console","Monitor suite_access_token acquisition success rate and alert on failures"],"tags":["token","weixin-cp","suite-access-token","authentication","apache-http-client","tp"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}