71 thoughts to “Angular 8 + Spring Boot: JWT Authentication with Spring Security example”

  1. hi, i want to set role from angular but it keep showing this error :
    Cannot deserialize instance of `java.util.HashSet` out of VALUE_STRING token
    I know role shouldn’t be a String but couldn’t find a solution to pass

  2. java.lang.RuntimeException: Error: Role is not found.
    I am getting null for the role in java server side controller class, and i am unable to register any user

  3. hi, i want to set role from angular but it keep showing this error :
    Cannot deserialize instance of `java.util.HashSet` out of VALUE_STRING token
    I know role shouldn’t be a String but couldn’t find a solution to pass : “role”: [“admin”]
    any tips ?

  4. Good morning, when i try to delete a user by his id
    it shows me this error msg: Cannot delete or update a parent row: a foreign key constraint fails..
    any solutions pls ?

  5. Hi,
    Can you please help me:
    I run your project and it still ok. But I found on my eclipse log that:
    io.jsonwebtoken.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted.
    It has this error. Can you help me fix this

  6. Hi,

    Imagine this application in a production environment. Apache for Frontend (Angular) and Wildfly for Backend (Springboot). My doubt is who makes the api REST calls to Backend, browser or Web Server (Apache)? Do you know some article to go deeper into the subject?

    Congrats and thanks by the post.


  7. I’m getting this error can u help me out,plz

    “Validation failed for object=’loginRequest’. Error count: 1”

  8. Hi,

    The JWT token that I receive in UI, is not the full token That I receive on calling the REST api through POSTMAN.
    For example :
    POSTMAN token : “accessToken”: “eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzb20iLCJpYXQiOjE1OTY5ODI5MTQsImV4cCI6MTU5NzA2OTMxNH0.Vx7915pjE96cJ9KQ_kAOtfgnmysED5wPYCkIR6582nDvxuBjWF3yo34ZajIxosI6kCimS1kZ5NauO8MLsv0MwQ”

    Token in UI : eyJhbGciOiJIUzUxMiJ9 … ZkoK_Y00wEmYwCvzQRJQ

    How to display the full token in UI.

    1. Hi, you can change these lines of code:

      {{ currentUser.accessToken.substring(0, 20) }} ...
      {{ currentUser.accessToken.substr(currentUser.accessToken.length - 20) }}

      to: {{ currentUser.accessToken }}

  9. hi guys In Angular when i register with username, email, password So i want to set role for account but not defaut . How can I do it?

  10. Hii.. How to change the role of the user from user to admin.
    Admin can chance a user role as admin.. How it is possible?

  11. Hello, I have a little problem with Swagger Integration. If I go to http://localhost:8080/swagger-ui.html , my console show this problem:
    javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup!

    Any suggestion please? thanks

  12. When i try to open user board i will get Unauthorized error: Full authentication is required to access this resource.
    This user has role ROLE_USER

  13. is it possible to change my jwt token in a specific interval using access token and refresh token (with remember me feature ) concept in this existing project.

  14. How can i add the feature to “keep me logged in” even after closing the browser.

      1. could you please share the source code to add the “remember me” feature in the existing project.

  15. Hey when I run the code, Im getting an unauthorized access error. Any advice

  16. ERROR 11876 — [nio-8080-exec-7] c.b.s.security.jwt.AuthEntryPointJwt : Unauthorized error: Full authentication is required to access this resource

    what might be wrong?

    1. Hi, maybe the HTTP request Header was wrong.
      Notice that you need to modify the code in app/_helpers/auth.interceptor.js to work with Spring Boot Server:

      authReq = req.clone({ headers: req.headers.set(TOKEN_HEADER_KEY, 'Bearer ' + token) });
  17. Hi BezKoder,
    You are great man. Its save a lot of time to the base project. I have followed your tutorials. It gives me a clear picture that how can I make more secure my application with Angular 8. I have subscribed to your youtube channel and I see a lot of good content over there. Good job man.

  18. Hi, Very good tutorial about this topic. Congrats.

    Where I can find source code? Is there any GitHub repo? Thx

    1. Hi, you can find github source code for backend and frontend in the tutorials I mentioned in Conclusion section 🙂

  19. Hi, can you please tell me how to signup ADMIN or Mod ADMIN just like the Users

  20. Bonjour,
    j’ai obtient le problème suivant
    Access to XMLHttpRequest at ‘http://localhost:8080/api/auth/signin’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.

    Malgré que j’ai ajouté au niveau de l’api rest le code suivant;@CrossOrigin(origins = “http://localhost:4200” ,allowedHeaders = “*”,allowCredentials = “true”)
    Quelqu’un peut m’aider?

    1. Hi, the server you used configures CORS for port 8081, so you have to run this Angular client with command: ng serve --port 8081 instead.

  21. I like the app, but by no means do I register constantly I get the following message: “Signup failed!
    Error: Role is not found. “The roll table is populated.

  22. thanks for this tutorial. this is so good :3
    How can I develop this with some functions CRUD ?
    Could you give me advices

  23. Hi bezkoder,
    Your tutorial really help a lot. I just want to ask about the database design because I don’t think if I made it correctly. It always says “error”: “Unsupported Media Type”,
    Could help me with this.

      1. Thank you for replying on my need bezkoder. I just want to see how to design the database clearly with a UI like dbeaver or sql management studio because I’m confused because I always work on frontend.Could you help me with this,like sending screenshots or snippets? (Database design for the 3 tables)

      1. thanks a lot bezkoder… i liked your source code…its running as mentioned in the tutorials…
        do you have anything good with search like amazon???

          1. Also, file upload, save it to file system, keep the reference in db and then fetch and show using angular & spring boot 🙂

  24. Hi, thank you for this Spring Boot & Angular 8 Authentication tutorial. Please make a Tutorial for OAuth2.

Comments are closed to reduce spam. If you have any question, please send me an email.