You have to these steps:
Check the Endpoint:Ensure you have a /authenticate endpoint in your controller that uses AuthenticationManager to authenticate users. For example:
@PostMapping("/authenticate") public ResponseEntity<?> createAuthenticationToken(@RequestBody AuthRequest authRequest) throws Exception { authenticationManager.authenticate( new UsernamePasswordAuthenticationToken(authRequest.getUsername(), authRequest.getPassword()) ); }
Configure AuthenticationManager:Verify that AuthenticationManager is set up correctly. For testing, you might want to use in-memory authentication like this:
@Autowired public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication() .withUser("usuario").password(passwordEncoder().encode("pass")).roles("USER"); }
JWT Utility:Ensure your JwtUtil class is properly generating and validating JWT tokens.
Request Format: Make sure your request includes Content-Type: application/json and that the JSON body is formatted correctly.
Check Logs:enter code hereReview application logs for any authentication errors or warnings.