As mentioned on Akka gRPC documentation (https://doc.akka.io/docs/akka-grpc/current/server/akka-http.html) we can interop with Akka Http.
According to sample, request can be rejected (if check fails). But when rejection occures, always getting "13 INTERNAL" error. How can we return UNAUTHENTICATED(16) instead of Internal error?
val authorizationDirective: Directive0 =
headerValueByName("token").flatMap { token =>
if (token == "XYZ") pass
else reject
}
also throwing exception did not work:
val authorizationDirective: Directive0 =
headerValueByName("token").flatMap { token =>
if (token == "XYZ") pass
else throw new AuthenticationException("Invalid Token!")
}
01:06:50.972|ERROR| akka.actor.ActorSystemImpl Error during processing of request: 'Invalid Token!'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
com.xworks.affixzone.api.integration.definition.exception.AuthenticationException: Invalid Token!
ps: I tried to use custom ExceptionHandler but it did not work.