A simple task manager API built using Spring Boot and secured with Google OAuth2 authentication. The API allows users to manage tasks with basic CRUD operations (Create, Read, Update, Delete) and integrates with a MySQL database for persistent data storage.
This project serves as an introduction to Spring Boot, OAuth2 integration, MySQL database management, and building secure APIs.
- OAuth2 Authentication: Users can authenticate using their Google accounts.
- CRUD Operations: Allows users to create, read, update, and delete tasks.
- MySQL Database: The application uses MySQL for data persistence.
- Spring Boot: The application is built using the Spring Boot framework, leveraging Spring Data JPA for database interaction.
- Java 17 or higher
- Spring Boot 3.x
- MySQL 8.x or a MySQL-compatible database (e.g., MariaDB)
- Gradle (for building the project)
git clone https://github.com/Marius-DeltaTime/TaskManagerAPI.git
cd TaskManagerAPI
- Install MySQL and set up a database (if you haven't already).
- Create a database named
task_manager_db
(or change the name inapplication.properties
). - Update
application.properties
with your database credentials:
spring.datasource.url=jdbc:mysql://localhost:3306/task_manager_db
spring.datasource.username=root
spring.datasource.password=<your_password>
spring.jpa.hibernate.ddl-auto=update
- Create a Google Developer project and enable OAuth2 authentication.
- Obtain your client ID and client secret from the Google API console.
- Add the following to your
application.properties
:
spring.security.oauth2.client.registration.google.client-id=${GOOGLE_CLIENT_ID}
spring.security.oauth2.client.registration.google.client-secret=${GOOGLE_CLIENT_SECRET}
spring.security.oauth2.client.registration.google.redirect-uri=http://localhost:8080/login/oauth2/code/{registrationId}
- Run the following command to build the project:
./gradlew clean build
- Start the Spring Boot application:
./gradlew bootRun
- Open the application in your browser at
http://localhost:8080
.
Once the app is running, you can test the OAuth2 authentication and task management endpoints.
- OAuth2 Login: Go to
/login
and authenticate using Google. - CRUD Endpoints: You can perform CRUD operations on tasks via REST endpoints.