From 2412df32ffef94071497c060e5973d8b92550214 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 7 Dec 2023 16:36:17 +0800 Subject: [PATCH] =?UTF-8?q?:art=EF=BC=9A=20=E4=BC=98=E5=8C=96=E5=BC=80?= =?UTF-8?q?=E6=94=BE=E5=B9=B3=E5=8F=B0=E6=A8=A1=E5=9D=97OAuth2=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=B1=BB=E7=9A=84=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java | 9 +++++++-- .../open/api/impl/WxOpenOAuth2ServiceImplTest.java | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java index 6f599dc29..04e3bf82c 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImpl.java @@ -1,6 +1,5 @@ package me.chanjar.weixin.open.api.impl; -import lombok.AllArgsConstructor; import me.chanjar.weixin.common.bean.WxOAuth2UserInfo; import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; import me.chanjar.weixin.common.enums.WxType; @@ -9,6 +8,7 @@ import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.service.WxOAuth2Service; import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; import me.chanjar.weixin.common.util.http.URIUtil; +import me.chanjar.weixin.open.api.WxOpenConfigStorage; import org.apache.commons.lang3.StringUtils; import java.io.IOException; @@ -22,11 +22,16 @@ import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Other.QRCONNECT_URL; * @author Binary Wang * created on 2020-10-19 */ -@AllArgsConstructor public class WxOpenOAuth2ServiceImpl extends WxOpenServiceImpl implements WxOAuth2Service { private final String appId; private final String appSecret; + public WxOpenOAuth2ServiceImpl(String appId, String appSecret, WxOpenConfigStorage openConfigStorage) { + this.appId = appId; + this.appSecret = appSecret; + super.setWxOpenConfigStorage(openConfigStorage); + } + @Override public String buildAuthorizationUrl(String redirectUri, String scope, String state) { return String.format(QRCONNECT_URL.getUrl(null), diff --git a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImplTest.java b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImplTest.java index e65a66241..6b1fce3bb 100644 --- a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImplTest.java +++ b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenOAuth2ServiceImplTest.java @@ -12,11 +12,12 @@ import org.testng.annotations.Test; * created on 2020-10-19 */ public class WxOpenOAuth2ServiceImplTest { - private final WxOpenOAuth2ServiceImpl service = new WxOpenOAuth2ServiceImpl("123", ""); + private final WxOpenOAuth2ServiceImpl service = new WxOpenOAuth2ServiceImpl("123", "", + new WxOpenInMemoryConfigStorage()); @BeforeTest public void init() { - this.service.setWxOpenConfigStorage(new WxOpenInMemoryConfigStorage()); +// this.service.setWxOpenConfigStorage(new WxOpenInMemoryConfigStorage()); } @Test