From 45aee17e4364ed0e1af6abf3a33e0a9770256e60 Mon Sep 17 00:00:00 2001 From: wanggeng888 <450292408@qq.com> Date: Sat, 22 May 2021 09:19:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B5=84=E6=BA=90=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AFtoken=E7=9A=84=E8=AF=B7=E6=B1=82=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=EF=BC=8C=E5=8F=AF=E4=BB=A5=E4=B8=8D=E8=B5=B0=E5=A4=96?= =?UTF-8?q?=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cm/common/plugin/oauth/token/ClientTokenManager.java | 7 ++++++- .../java/com/cm/common/plugin/startup/OAuthStartUp.java | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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); } }