server = $server; } /** * @param \Psr\Http\Message\ServerRequestInterface $request * @param \Psr\Http\Message\ResponseInterface $response * @param callable $next * * @return \Psr\Http\Message\ResponseInterface */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) { try { $request = $this->server->getResponseType()->determineAccessTokenInHeader($request); } catch (OAuthServerException $exception) { return $exception->generateHttpResponse($response); } catch (\Exception $exception) { return $response->withStatus(500)->write($exception->getMessage()); } // Pass the request and response on to the next responder in the chain return $next($request, $response); } }