- Integrate Google Login using Spring Boot OAuth2.
- Configure Spring Security to handle OAuth2 clients.
- Use
@AuthenticationPrincipal
to get Google user details. - Display profile info and support logout.
spring-boot-starter-oauth2-client
spring-boot-starter-security
spring-boot-starter-thymeleaf
-
Create a Google OAuth2 Client at https://console.cloud.google.com/
-
Add redirect URI:
http://localhost:8080/login/oauth2/code/google
-
Update your
application.yml
with your credentials. -
Run:
mvn spring-boot:run
-
Visit: http://localhost:8080/
-
Login with Google and see your name, email, and picture displayed