Spring Boot OAuth2 Social Login with Google Example

Published: 27 September 2020
on channel: Code Java
48,414
628

Learn how to implement social login using Google for an existing Spring Boot application using Spring Boot OAuth2 client library. And after successful OAuth2 authentication: Register new user if the user's info does not exist in the database, else update existing user's info.

Here are the steps to code social login with Google:
Create Google OAuth Credentials
Configure Spring Security OAuth2 Client
Update database table & Entity class (add info about authentication provider)
Update login page
Code Custom OAuth User & OAuth User Service classes
Configure Spring Security for OAuth2 authentication
Implement Authentication Success Handler
Update CustomerServices: register new / update existing user

Key technologies:
Spring Boot Web
Spring Data JPA
Spring Security
Spring OAuth2 Client
Thymeleaf
Bootstrap & jQuery
MySQL database

Software programs:
Java Development Kit (JDK)
Spring Tool Suite IDE (STS)
MySQL server & MySQL Workbench

For the companion tutorial, visit: https://www.codejava.net/frameworks/s...