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) { if ($request->hasHeader('authorization') === false) { $exception = OAuthServerException::accessDenied('Missing authorization header'); return $exception->generateHttpResponse($response); } $request = $this->server->getResponseType()->determineAccessTokenInHeader($request); if ($request->getAttribute('oauth_access_token') === null) { $exception = OAuthServerException::accessDenied($request->getAttribute('oauth_access_token_error')); return $exception->generateHttpResponse($response); } // Pass the request and response on to the next responder in the chain return $next($request, $response); } }