old mode 100644
new mode 100755
| | |
| | | |
| | | |
| | | @Java110Synchronized(value = "hc_get_token") |
| | | public static String get(RestTemplate restTemplate) { |
| | | public static String get(RestTemplate restTemplate,boolean refreshAccessToken) { |
| | | String token = CommonCache.getValue(IotConstant.HC_TOKEN); |
| | | if (!StringUtil.isEmpty(token)) { |
| | | if (!StringUtil.isEmpty(token) && !refreshAccessToken) { |
| | | return token; |
| | | } |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | HttpEntity httpEntity = new HttpEntity(headers); |
| | | ResponseEntity<String> tokenRes = restTemplate.exchange(IotConstant.GET_TOKEN_URL, HttpMethod.GET, httpEntity, String.class); |
| | | String url = IotConstant.getUrl(IotConstant.GET_TOKEN_URL.replace("APP_ID", IotConstant.getAppId()).replace("APP_SECRET", IotConstant.getAppSecret())); |
| | | ResponseEntity<String> tokenRes = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); |
| | | |
| | | if (tokenRes.getStatusCode() != HttpStatus.OK) { |
| | | throw new IllegalArgumentException("获取token失败" + tokenRes.getBody()); |