com.wacai.file.token.ApplyToken Maven / Gradle / Ivy
package com.wacai.file.token;
import com.wacai.file.token.response.AccessToken;
import com.wacai.file.token.util.SignUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
/**
* Created by fulushou on 2018/5/10.
*/
public class ApplyToken {
RestTemplate restTemplate = new RestTemplate();
private String appKey;
private String appSecret;
private String gatewayAuthUrl;
public ApplyToken(String appKey, String appSecret, String gatewayAuthUrl) {
this.appKey = appKey;
this.appSecret = appSecret;
this.gatewayAuthUrl = gatewayAuthUrl;
}
public AccessToken refreshAccessToken(String refreshToken) {
long timestamp = System.currentTimeMillis();
String sign = SignUtil.generateSign(appKey + "refresh_token" + refreshToken + timestamp,
appSecret);
MultiValueMap body = new LinkedMultiValueMap();
body.add("app_key", appKey);
body.add("grant_type", "refresh_token");
body.add("timestamp", String.valueOf(timestamp));
body.add("refresh_token", refreshToken);
body.add("sign", sign);
final HttpEntity> request = new HttpEntity>(body);
ResponseEntity
© 2015 - 2025 Weber Informatics LLC | Privacy Policy