Skip to content

Commit e8e6af3

Browse files
committed
✨ spring-boot-demo-oauth 微信 登录完成
1 parent ad8d343 commit e8e6af3

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

spring-boot-demo-oauth/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<dependency>
5050
<groupId>me.zhyd.oauth</groupId>
5151
<artifactId>JustAuth</artifactId>
52-
<version>1.0.1</version>
52+
<version>1.2.0</version>
5353
</dependency>
5454

5555
<dependency>

spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/config/props/OAuthProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ public class OAuthProperties {
2626
* github 配置
2727
*/
2828
private CommonProperties github;
29+
private CommonProperties wechat;
2930
}

spring-boot-demo-oauth/src/main/java/com/xkcoding/oauth/controller/OauthController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import me.zhyd.oauth.model.AuthSource;
99
import me.zhyd.oauth.request.AuthGithubRequest;
1010
import me.zhyd.oauth.request.AuthRequest;
11+
import me.zhyd.oauth.request.AuthWeChatRequest;
1112
import org.springframework.beans.factory.annotation.Autowired;
1213
import org.springframework.web.bind.annotation.PathVariable;
1314
import org.springframework.web.bind.annotation.RequestMapping;
@@ -66,6 +67,8 @@ private AuthRequest getAuthRequest(String oauthType) {
6667
switch (authSource) {
6768
case GITHUB:
6869
return getGithubAuthRequest();
70+
case WECHAT:
71+
return getWechatAuthRequest();
6972
default:
7073
throw new RuntimeException("暂不支持的第三方登录");
7174
}
@@ -75,6 +78,10 @@ private AuthRequest getGithubAuthRequest() {
7578
return new AuthGithubRequest(buildAuthConfig(properties.getGithub()));
7679
}
7780

81+
private AuthRequest getWechatAuthRequest() {
82+
return new AuthWeChatRequest(buildAuthConfig(properties.getWechat()));
83+
}
84+
7885
private AuthConfig buildAuthConfig(CommonProperties properties) {
7986
return AuthConfig.builder()
8087
.clientId(properties.getClientId())

spring-boot-demo-oauth/src/main/resources/application.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ oauth:
77
github:
88
client-id: 2d25a70d12e3d5f01086
99
client-secret: 5a2919b5fe911567343aea2ccc7a5ad7871306d1
10-
redirect-uri: http://oauth.xkcoding.com/demo/oauth/github/callback
10+
redirect-uri: http://oauth.xkcoding.com/demo/oauth/github/callback
11+
wechat:
12+
client-id:
13+
client-secret:
14+
redirect-uri: http://oauth.xkcoding.com/demo/oauth/wechat/callback

0 commit comments

Comments
 (0)