0

Which exception used to check the wrong authentication if i am using REST POST service to send a json to another micro service in java/Spring boot. For Authentication i am using "bearer token". Is it HttpServerErrorException or HttpCLientException ?

GhostA
  • 35
  • 4
  • I'm not really sure what are you asking there, but usually a failed authentication should result in error `403` which is a client exception. – Ervin Szilagyi Feb 22 '19 at 12:56

1 Answers1

0

See the second answer for this question: "How do I return a 403 forbbiden in spring"

You can throw "AccessDeniedException" to specify an authorization problem. And to clarify, the "HttpServerErrorException" is thrown when an internal problem has ocurred (500 status code). The other exception, "HttpClientException", is an Java exception, I mean, not from spring-boot, and is a more general one, anyway you can use it too.

Marco Marchetti
  • 187
  • 1
  • 6
  • 14