fix: 获取token优化
This commit is contained in:
@@ -403,7 +403,7 @@ public class RefinitivConsumer implements ApplicationRunner {
|
|||||||
.basicAuth(appKey,"")
|
.basicAuth(appKey,"")
|
||||||
.execute();
|
.execute();
|
||||||
if(response.getStatus() != 200){
|
if(response.getStatus() != 200){
|
||||||
throw new SysTipsException("获取token失败");
|
return getNewToken();
|
||||||
}
|
}
|
||||||
JSONObject data = JSONObject.parseObject(response.body());
|
JSONObject data = JSONObject.parseObject(response.body());
|
||||||
data.put("expiry_tm",System.currentTimeMillis() + (Long.valueOf(data.get("expires_in").toString())-10));
|
data.put("expiry_tm",System.currentTimeMillis() + (Long.valueOf(data.get("expires_in").toString())-10));
|
||||||
@@ -412,6 +412,27 @@ public class RefinitivConsumer implements ApplicationRunner {
|
|||||||
redisTemplate.expire("token",1, TimeUnit.DAYS);
|
redisTemplate.expire("token",1, TimeUnit.DAYS);
|
||||||
return toekn;
|
return toekn;
|
||||||
}
|
}
|
||||||
|
// HttpResponse response = HttpUtil.createPost(tokenUrl)
|
||||||
|
// .form("username",tokenUsername)
|
||||||
|
// .form("password",tokenPassword)
|
||||||
|
// .form("grant_type","password")
|
||||||
|
// .form("scope",SCOPE)
|
||||||
|
// .form("takeExclusiveSignOnControl","true")
|
||||||
|
// .header("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
// .basicAuth(appKey,"")
|
||||||
|
// .execute();
|
||||||
|
// if(response.getStatus() != 200){
|
||||||
|
// throw new SysTipsException("获取token失败");
|
||||||
|
// }
|
||||||
|
// JSONObject data = JSONObject.parseObject(response.body());
|
||||||
|
// data.put("expiry_tm",System.currentTimeMillis() + (Long.valueOf(data.get("expires_in").toString())-10));
|
||||||
|
// String toekn = data.toString();
|
||||||
|
// redisTemplate.opsForValue().set("token",toekn);
|
||||||
|
// redisTemplate.expire("token",1, TimeUnit.DAYS);
|
||||||
|
return getNewToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewToken(){
|
||||||
HttpResponse response = HttpUtil.createPost(tokenUrl)
|
HttpResponse response = HttpUtil.createPost(tokenUrl)
|
||||||
.form("username",tokenUsername)
|
.form("username",tokenUsername)
|
||||||
.form("password",tokenPassword)
|
.form("password",tokenPassword)
|
||||||
|
|||||||
Reference in New Issue
Block a user