{"record":{"id":"8e145bfc55b14607","repo":"binarywang/WxJava","slug":"error-8e145b","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/WxCpTpServiceOkHttpImpl.java","lineNumber":88,"sourceCode":"      Request request = new Request.Builder()\n        .url(this.configStorage.getApiUrl(WxCpApiPathConsts.Tp.GET_SUITE_TOKEN)) // URL 不包含查询参数\n        .post(requestBody) // 使用 POST 方法\n        .build();\n\n      String resultContent = null;\n      try (Response response = client.newCall(request).execute()) {\n        if (!response.isSuccessful()) {\n          throw new IOException(\"Unexpected response code: \" + response);\n        }\n        resultContent = response.body().string();\n      } catch (IOException e) {\n        log.error(\"获取 suite token 失败: {}\", e.getMessage(), e);\n        throw new WxRuntimeException(\"获取 suite token 失败\", e);\n      }\n\n      WxError error = WxError.fromJson(resultContent, WxType.CP);\n      if (error.getErrorCode() != 0) {\n        throw new WxErrorException(error);\n      }\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    }\n    return this.configStorage.getSuiteAccessToken();\n  }\n\n  @Override\n  public void initHttp() {\n    log.debug(\"WxCpServiceOkHttpImpl initHttp\");\n    //设置代理\n    if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {\n      httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(),\n        configStorage.getHttpProxyPort(),\n        configStorage.getHttpProxyUsername(),","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpServiceOkHttpImpl.java#L70-L106","documentation":"Thrown as WxErrorException when the OkHttp implementation of getSuiteAccessToken() receives a non-zero error code from the suite_access_token endpoint. The request completed at the HTTP level (no IOException) but WeChat returned an error JSON. Identical logic to errors 164-166 but using OkHttp as the transport. Message format from WxError.toString().","triggerScenarios":"Suite access token request completes but returns errcode != 0: invalid suite_secret (640001), expired suite_ticket (40029), invalid suite_id (40098), or IP whitelist violation (60020).","commonSituations":"suite_secret mismatch; suite_ticket expired or not received; server IP not in whitelist; suite application under review.","solutions":["Verify suite_id and suite_secret exactly match the Third-Party Platform console settings","Ensure suite_ticket is being received and stored before it expires","Whitelist your server's public IP in the WeChat TP admin console","Inspect WxError errorCode for the specific failure reason"],"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  log.error(\"OkHttp suite token error: code={}, msg={}\",\n    error.getErrorCode(), error.getErrorMsg());\n  throw e;\n}","preventionTips":["Verify suite_id and suite_secret match the TP console","Ensure suite_ticket callback is functional and tickets are stored promptly","Whitelist your server IP in the TP admin console","Monitor suite_access_token acquisition success rate"],"tags":["token","weixin-cp","suite-access-token","authentication","okhttp","tp"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}