Spring-Boot-Blog-REST-API
Spring-Boot-Blog-REST-API copied to clipboard
401 response on homepage
Describe the bug Cloned the repo and followed the readme but I get 401 error. Screenshot is attached.
To Reproduce Steps to reproduce the behavior:
- Follow the Readme.
- Update MySQL username and password in both
_application.propertiesandapplication.ymlfiles (in folder src/main/resources). - In
application.yml, replace "blogapi-db:3306" with "localhost:3306" - In
pom.xml, update lombok version to 1.18.22 to solve a build issue. - Run
mvn spring-boot:run - Access
http://localhost:8080on browser.
Expected behavior Homepage should be seen without errors.
Screenshots
Desktop (please complete the following information):
- OS: Windows10
- Browser: Brave
- Version: [Version 1.51.118 Chromium: 113.0.5672.126 (Official Build) (64-bit)]
Welcome @arvindpdmn to Spring-Boot-Blog-REST-API community! Thanks so much for creating your first issue :)
@arvindpdmn You have to check it on Postman.
- The repository uses Java 11 (and you should to). That would solve the Lombok issue without needing to change what is existing in the POM file.
- Remember that a REST API is a back-end only. Meaning text and in this case JSON is the only thing that is received by the client from the server. Download applications like Postman or Insomnia that allow you to easily run APIs. For sign up: you would choose POST and enter http://localhost:8080/api/auth/signup then for the body choose JSON and enter the example JSON in the README.
- To use most of the APIs you need to sign in. So with the user you just created, use the sign in API. Make sure to save the accessToken (it always starts with "ey" since it's a JWT) as it is the Authorization/Auth that needs to be inserted as the Bearer token in future requests so the API knows you are signed in.