Commit 76b3b60a authored by Quxl's avatar Quxl

x

parent a3880ef8
......@@ -335,7 +335,7 @@ public interface OAuthApi {
}
/**
* 系统授权成功后,用户和通过此方法访问应用接口(因甲方未提供相关接口请求数据格式和鉴权设置等信息, 此处只按标准OAuth授权后的请求流程进行操作, 如有出入,用户可以根据实际情况, 重写或重载此方法)
* 系统授权成功后,用户和通过此方法访问应用接口(因甲方未提供相关接口请求数据格式和鉴权设置等信息, 此处只按标准OAuth授权后的请求流程进行操作, 如有出入,用户可以根据实际情况, 重写或重载此方法)
* @param url 访问URL
* @param headers HTTP头信息
* @param data HTTP请求参数
......@@ -343,28 +343,19 @@ public interface OAuthApi {
*/
default String doPost(String url, Map<String, String> headers, JSONObject data) {
try {
String jsonData = data == null ? "" : data.toString();
logger.debug("oauth post url: " + url);
logger.debug("oauth post headers: " + JSON.toJSONString(headers));
logger.debug("oauth post data: " + data.toJSONString());
logger.debug("oauth post data: " + jsonData);
OAuthToken token = this.getOAuthToken();
if(System.currentTimeMillis() - token.getCreateMillis() > ((token.getExpiresIn()-5) * 1000)) {
this.refreshOAuthToken();
token = this.getOAuthToken();
}
String accept = "application/json";
String requestId = ("" + System.currentTimeMillis());
String countryCode = System.getProperty("X-SE-IFW-CountryCode");
String languageCode = System.getProperty("X-SE-IFW-LanguageCode");
String applicationName = System.getProperty("X-SE-IFW-ApplicationName");
headers.put("Accept", accept);
headers.put("X-SE-IFW-RequestId", requestId);
headers.put("X-SE-IFW-CountryCode", countryCode);
headers.put("X-SE-IFW-LanguageCode", languageCode);
headers.put("X-SE-IFW-ApplicationName", applicationName);
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
String accessToken = token.getAccessToken();
OAuthClientRequest clientRequest = new OAuthBearerClientRequest(url).setAccessToken(accessToken).buildQueryMessage();
clientRequest.setBody(data.toString());
clientRequest.setBody(jsonData);
clientRequest.setHeaders(headers);
OAuthResourceResponse resourceResponse = oAuthClient.resource(clientRequest, "POST", OAuthResourceResponse.class);
String resBody = resourceResponse.getBody();
......
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