Hi
My client was sending incorrect JWT token and Silhouette correctly responded with 401
. I have created a custom error handler (extends HttpErrorHandler) so that I can send my application specific error response (JSON). But I notice that it wasn’t called when the authentication failed? Why?
I enabled debugging to see whats going on.
I found that Silhouette throws an error but I think the error is thrown before my Controller could handle it. The error is thrown at the entry point of the controller’s definition
def newQuestion = silhouette.SecuredAction.async(parse.json) {
The error was
com.mohiva.play.silhouette.api.exceptions.AuthenticatorException: [Silhouette][jwt-authenticator] Error on parsing JWT token: eyJ...
at com.mohiva.play.silhouette.impl.authenticators.JWTAuthenticator$$anonfun$unserialize$5.applyOrElse(JWTAuthenticator.scala:154)111```
How can I handle this error and how can I use my custom error handler to send custom response?
thanks