🔒 A Java Spring Boot application demonstrating Google OAuth2 authentication integration.
This project implements user authentication via Google accounts using OAuth2 in a Spring Boot application.
After a successful login, users can access protected resources within the app.
- Java 17
- Spring Boot 3.2
- Spring Security
- Spring Security OAuth2 Client
- Maven
- Google OAuth2 API
-
Clone the repository
git clone https://github.com/IvashDima/JavaPro_HW14_SprSecGoogle.git
-
Navigate to the project directory:
cd JavaPro_HW14_SprSecGoogle
-
Configure OAuth2 credentials Create a project in Google Cloud Console, configure OAuth2 Client credentials, and update src/main/resources/application.properties:
spring.security.oauth2.client.registration.google.client-id=your-google-client-id spring.security.oauth2.client.registration.google.client-secret=your-google-client-secret spring.security.oauth2.client.registration.google.scope=openid,email,profile
-
Build and Run
mvn spring-boot:run
-
Access the application Open your browser and navigate to:
http://localhost:8886/
You will be redirected to the Google login page.
src/
└── main/
├── java/
│ └── org/example/springsecurity/
│ ├── controllers/ # Controllers handling HTTP requests
│ ├── config/ # OAuth2 security configuration
│ └── SpringSecurityApplication.java # Main application class
├── resources/
│ └── application.properties # Application configuration
└── webapp/WEB-INF/pages # JSTL templates
Google might require OAuth2 consent screen verification for apps requesting sensitive scopes.
Always protect sensitive information (like client secret) in production (use environment variables, vaults, etc.).
This project is educational and focuses on OAuth2 integration basics.
Name: Dmytro Ivashchenko
Email: dnytsyk@gmail.com
This project is provided for educational purposes only and does not have a specific license. Feel free to use and adapt it for your learning and personal projects!