protected function getUnauthorizedResponse($statusCode, $error = null)
    {
        $authenticateHeader  = 'Bearer';
        $authenticateHeader .= $error === null ? '' : sprintf(' error="%s"', $error);

        $body    = ['message' => 'Unauthorized'];
        $headers = ['WWW-Authenticate' => $authenticateHeader];

        return new JsonResponse($body, $statusCode, $headers);
    }