|
@@ -319,6 +319,63 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getLiveKuaiShouAgentRefreshToken(String id , String accessToken, String refreshToken, Long appId, String secret) {
|
|
|
+ log.info("快手刷新token入参,token:{},refreshToken:{}", accessToken, refreshToken);
|
|
|
+ String url = kuaishouApiUrl + "/rest/openapi/oauth2/authorize/refresh_token";
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+
|
|
|
+ param.put("app_id", appId);
|
|
|
+ param.put("secret", secret);
|
|
|
+ param.put("refresh_token", refreshToken);
|
|
|
+ try {
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ log.info("快手刷新代理商token返回结果:{}", refreshToken);
|
|
|
+ if (Check.isNull(resultJson)) {
|
|
|
+ log.error("快手刷新代理商token返回结果为空,token:{}", accessToken);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ if (null == code || code != 0) {
|
|
|
+ log.error("快手刷新代理商token失败,token:{},result:{}", accessToken, resultJson);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
+ if (null == dataJson) {
|
|
|
+ log.error("快手刷新代理商token失败,token:{},result:{}", accessToken, resultJson);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
|
|
|
+ agentTokenQueryWrapper.eq("id", id);*/
|
|
|
+ OauthAgentToken updateAgentToken = new OauthAgentToken();
|
|
|
+ updateAgentToken.setId(id);
|
|
|
+ updateAgentToken.setAccessToken(dataJson.getString("access_token"));
|
|
|
+ updateAgentToken.setRefreshToken(dataJson.getString("refresh_token"));
|
|
|
+ long accessTokenExpireIn = dataJson.getLong("access_token_expires_in") * 1000L;
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ Date accessTokenExpireInDate = new Date(now + accessTokenExpireIn);
|
|
|
+ updateAgentToken.setAccessTokenExpiresIn(accessTokenExpireInDate);
|
|
|
+ long refreshTokenExpireIn = dataJson.getLong("refresh_token_expires_in") * 1000L;
|
|
|
+ Date refreshTokenExpireInDate = new Date(now + refreshTokenExpireIn);
|
|
|
+ updateAgentToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
|
|
|
+ updateAgentToken.setUpdateTime(new Date());
|
|
|
+ int update = agentTokenMapper.updateLiveById(updateAgentToken);
|
|
|
+ if (update > 0) {
|
|
|
+ log.info("刷新代理商token完成");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ log.error("快手刷新代理商token失败,token{}", accessToken);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<CtopOauthToken> queryKsValidRuleAccountsToken() {
|
|
|
return ctopOauthTokenMapper.queryKsValidRuleAccountsToken();
|