Commit 60fd1b79 authored by caotao's avatar caotao

户用光伏科士达获取token调整

parent f84ef9ab
...@@ -32,16 +32,17 @@ public class KSolarRequestUtil { ...@@ -32,16 +32,17 @@ public class KSolarRequestUtil {
public HashMap<String, Object> getHeader() { public HashMap<String, Object> getHeader() {
HashMap<String, Object> hashMap = new HashMap<>(); HashMap<String, Object> hashMap = new HashMap<>();
HashMap<String, Object> requsetParams = new HashMap<>(); HashMap<String, Object> requsetParams = new HashMap<>();
String requestParam="";
HashMap<String, String> hashMaphead = new HashMap<>(); HashMap<String, String> hashMaphead = new HashMap<>();
requsetParams.put("username", KSolarConstant.account);
try { try {
requsetParams.put("password", AESUtils.Encrypt(KSolarConstant.password, AESUtils.DEFAULT_SECRET_KEY)); requestParam = "username="+KSolarConstant.account+"&password="+AESUtils.Encrypt(KSolarConstant.password, AESUtils.DEFAULT_SECRET_KEY);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
String url = KSolarConstant.baseurl + KSolarConstant.tokenUrl; String url = KSolarConstant.baseurl + KSolarConstant.tokenUrl;
hashMaphead.put("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
hashMaphead.put("Authorization", "Basic " + Base64.getUrlEncoder().encodeToString((KSolarConstant.authUsername + ":" + KSolarConstant.authPassword).getBytes(StandardCharsets.UTF_8))); hashMaphead.put("Authorization", "Basic " + Base64.getUrlEncoder().encodeToString((KSolarConstant.authUsername + ":" + KSolarConstant.authPassword).getBytes(StandardCharsets.UTF_8)));
String ResPonse = HttpUtil.createPost(url).headerMap(hashMaphead, false).body(JSONObject.toJSONString(requsetParams)).execute().body(); String ResPonse = HttpUtil.createPost(url).headerMap(hashMaphead, false).body(requestParam).execute().body();
return hashMap; return hashMap;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment