Task Management API
July 9, 2023 · View on GitHub
This is a repository for the Spring Boot project. The project uses Spring Boot with Java 11 and integrates with Postman for API testing.
Prerequisites
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Running the Application Locally
-
Clone the repository:
git clone https://github.com/ConnorDBurge/TaskManagementAPI.git -
Navigate into the directory:
cd TaskManagementAPI -
Run the Spring Boot application:
mvn spring-boot:runOr if you prefer to package the application as a
.jarfile and then run it, you can use the following commands:mvn clean package java -jar target/myproject-0.0.1-SNAPSHOT.jar
Setting Up Postman
- Download and install Postman from Postman's official site.
- Launch Postman and sign in or sign up.
Importing Postman Collection
- In Postman, click on the "Import" button.
- Click on "Link".
- Paste the following link into the textbox: Postman Collection
- Click on "Continue" and then "Import" to confirm.
Running Our Collection
- After importing, you can see our collection in the "Collections" sidebar.
- Click on the collection name to expand it and see the different API requests.
Authentication
Note: By including the Authorization header with the Bearer <authentication_token> value, you simulate an authenticated request in Postman. The backend will then validate the token and allow access to the authenticated endpoint.
Obtaining an authentication token:
- Send a
POSTrequest to the backend/v1/auth/signinendpoint with valid credentials. - A script stores the
accessTokenas an environment variable in Postman and is used in all other HTTP calls.
This is for your convenience. You won’t need to copy and paste it anywhere.
Testing the authenticated endpoints:
- Make the request to the authenticated endpoint (eg.
/v1/users,/v1/tasks) in Postman. - The backend will validate the authentication token included in the
Authorizationheader and process the request accordingly. The response will contain the JSON body if the token was valid.
- If you receive a status
401, the API is properly working. You just need a new token. See Obtaining an authentication token section. - If you receive a status
500, there was an internal server error. Attempt to create a new user using the/v1/auth/signupendpoint. If you receive a status2xx, you can sign in using step 1 in Obtaining an authentication token section. Otherwise, there is a bug.
Endpoints
Built With
- Spring Boot - The web framework used
- Maven - Dependency Management
- Java 11 - Used to write the application
- Postman - API Development Environment
License
This project is licensed under the MIT License - see the LICENSE.md file for details