调整资源客户端token的请求地址,可以不走外网
This commit is contained in:
parent
717628ed54
commit
45aee17e43
@ -1,6 +1,7 @@
|
||||
package com.cm.common.plugin.oauth.token;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.config.properties.ApiPathProperties;
|
||||
import com.cm.common.config.properties.OauthClientProperties;
|
||||
import com.cm.common.config.properties.OauthProperties;
|
||||
import com.cm.common.plugin.pojo.bos.ClientTokenBO;
|
||||
@ -30,6 +31,7 @@ public class ClientTokenManager {
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
private OauthProperties oauthProperties;
|
||||
private OauthClientProperties oauthClientProperties;
|
||||
private ApiPathProperties apiPathProperties;
|
||||
|
||||
private ClientTokenManager() {
|
||||
}
|
||||
@ -50,7 +52,7 @@ public class ClientTokenManager {
|
||||
params.put("client_id", oauthClientProperties.getClientId());
|
||||
params.put("client_secret", oauthClientProperties.getClientSecret());
|
||||
params.put("scope", "all");
|
||||
String result = restTemplateUtil.doPostFormNormal(String.format("%s/oauth_client/token", oauthProperties.getOauthServer()), params);
|
||||
String result = restTemplateUtil.doPostFormNormal(String.format("%s/oauth_client/token", apiPathProperties.getUserCenter()), params);
|
||||
if (StringUtils.isBlank(result)) {
|
||||
LOG.error("客户端获取token失效");
|
||||
} else {
|
||||
@ -95,4 +97,7 @@ public class ClientTokenManager {
|
||||
public static ClientTokenManager clientTokenManager = new ClientTokenManager();
|
||||
}
|
||||
|
||||
public void setApiPathProperties(ApiPathProperties apiPathProperties) {
|
||||
this.apiPathProperties = apiPathProperties;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.cm.common.plugin.startup;
|
||||
|
||||
import com.cm.common.config.properties.ApiPathProperties;
|
||||
import com.cm.common.config.properties.OauthClientProperties;
|
||||
import com.cm.common.config.properties.OauthProperties;
|
||||
import com.cm.common.plugin.oauth.token.ClientTokenManager;
|
||||
@ -27,6 +28,8 @@ public class OAuthStartUp implements ApplicationRunner {
|
||||
@Autowired
|
||||
private OauthProperties oauthProperties;
|
||||
@Autowired
|
||||
private ApiPathProperties apiPathProperties;
|
||||
@Autowired
|
||||
private RestTemplateUtil restTemplateUtil;
|
||||
|
||||
@Override
|
||||
@ -35,5 +38,6 @@ public class OAuthStartUp implements ApplicationRunner {
|
||||
clientTokenManager.setRestTemplateUtil(restTemplateUtil);
|
||||
clientTokenManager.setOauthProperties(oauthProperties);
|
||||
clientTokenManager.setOauthClientProperties(oauthClientProperties);
|
||||
clientTokenManager.setApiPathProperties(apiPathProperties);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user