视频演示: https://www.bilibili.com/video/BV1M54y1z7A9/
需要完成以下步骤:
- 创建工程并引入依赖包
-
spring-boot-starter-oauth2-client
-
spring-boot-starter-security
-
spring-boot-starter-web
-
-
创建Security配置信息
-
创建Github、Google的client-id和client-secret
#Oauth2GoogleLoginApplication.java
package com.deepincoding.oauth2googlelogin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Oauth2GoogleLoginApplication {
public static void main(String[] args) {
SpringApplication.run(Oauth2GoogleLoginApplication.class, args);
}
}
#MessageController.java