diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/token/ClientTokenManager.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/token/ClientTokenManager.java index 9d33e86..04b0dea 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/token/ClientTokenManager.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/token/ClientTokenManager.java @@ -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; + } } diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/startup/OAuthStartUp.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/startup/OAuthStartUp.java index 19d7104..150b763 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/startup/OAuthStartUp.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/startup/OAuthStartUp.java @@ -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); } }