TokenTest.java
3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.erry.iclear.dateInterface;
import com.arronlong.httpclientutil.HttpClientUtil;
import com.arronlong.httpclientutil.common.HttpConfig;
import com.erry.iclear.dateInterface.api.response.TokenResult;
import com.erry.iclear.dateInterface.util.HttpUtils;
import com.erry.iclear.dateInterface.util.JsonToJava;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.Map;
public class TokenTest extends IClearApiApplicationTests {
@Value("${api.token-info.username}")
String username;
@Value("${api.token-info.password}")
String password;
@Value("${api.address.token-url}")
String tokenUrl;
@Value("${api.address.refresh-token-url}")
String refreshTokenUrl;
@Value("${api.address.customs-url}")
String customsUrl;
@Value("${api.address.complete-msg-url}")
String completeMsgUrl;
@Test
public void token() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
map.put("username", this.username);
map.put("password", this.password);
HttpConfig config = HttpConfig.custom()
.url(tokenUrl)
.map(map)
.encoding("utf-8");
String token = HttpClientUtil.post(config);
TokenResult rss = JsonToJava.parseJson(token, TokenResult.class);
System.out.println(token);
System.out.println(refreshTokenUrl);
token = "eyJhbGciOiJSUzI1NiJ9.eyJleHBpcmVBdCI6MTYyNzQ3MTkyNjIxMCwidXNlcklkIjoiaWNsZWFyX2V4dGVybmFsX2N0bSJ9.dGrNuB8yHkeDM2Cmxwa7tej30fxQ6BpKYieWYh2kaW_nx75Hit8wy3FiLZTEgfXqa4o2axJEslrPgzedle5j5PIlTl-vz1WcCKDvLAh0PNeCX6i7NmpMKwemPAJp8gdo1HYjMdJPn7cV7Cjc7rSS1zjS4NCu0Ob7Qjf_FKopBYYJUITGy79Y0XbDo9_tHxS-2_8ahU3q78l799amQughnnMU3srpD9PLyKNO8uz6l-eV6ShSfYNE0o2L1FSH8xgqpIKNrRsl-JKasHIQl-82CiX-2XEtFFU4JbxDp9t-7jo-UlEIIKWk1Gy10nVC9FSntFFIHgTJ2lMAxF7QqI3QlQ";
Map<String,Object> map1 = new HashMap<String,Object>();
map1.put("token", token);
HttpConfig config1 = HttpConfig.custom()
.url(refreshTokenUrl)
.map(map1)
.encoding("utf-8");
String rs = HttpClientUtil.post(config1);
System.out.println(rs);
}
public static void main(String[] args) throws Exception{
// Map<String,Object> map = new HashMap<String,Object>();
// map.put("username", "iclear_export_prod");
// map.put("password", "1qaz@WSX");
// HttpConfig config = HttpConfig.custom()
// .url("https://apictm.iclrccd-fedex.com/login")
// .map(map)
// .encoding("utf-8");
// String token = HttpClientUtil.post(config);
// System.out.println(token);
Map<String,String> map = new HashMap<String,String>();
map.put("username", "iclear_export_prod");
map.put("password", "1qaz@WSX");
// HttpConfig config = HttpConfig.custom()
// .url("https://apictm.iclrccd-fedex.com/login")
// .map(map)
// .encoding("utf-8");
// String token = HttpClientUtil.post(config);
//
// String json = JSONObject.toJSONString(map);
// String str = executePost("https://apictm.iclrccd-fedex.com/login",json,20000);
// System.out.println(token);
String json = "{\"username\":\"iclear_export_prod\",\"password\":\"1qaz@WSX\"}";
String token = httpUtils.doPost(url,map);
System.out.println(token);
}
private static String url = "https://apictm.iclrccd-fedex.com/login";
private static String charset = "utf-8";
private static HttpUtils httpUtils = new HttpUtils();
}