/**
  * {@inheritdoc}
  */
 public function start(Request $request, AuthenticationException $authException = null)
 {
     $authenticateHeader = sprintf('Bearer realm=%s', $this->quotedString($this->realmName));
     if ($authException instanceof OAuthExceptionInterface) {
         $authenticateHeader .= sprintf(', error="%s"', $authException->getErrorCode());
         $authenticateHeader .= sprintf(', error_description=%s', $this->quotedString($authException->getMessage()));
     }
     if (null !== $this->logger) {
         $this->logger->debug('WWW-Authenticate header sent.', ['header' => $authenticateHeader]);
     }
     $response = new Response();
     $response->headers->set('WWW-Authenticate', $authenticateHeader);
     $response->setStatusCode(401);
     return $response;
 }