public function index(Request $request, Response $response) { $helper = $this->helper; if ($helper->hasAccessToken()) { $client = new \GuzzleHttp\Client(); $fileResponse = $client->get('https://www.googleapis.com/drive/v2/files', ['headers' => $helper->getAuthorizedHeaders()]); $files = new Files($fileResponse->getBody()); return $this->view->render($response, 'files.twig', ['files' => $files->formatData(), 'area' => self::AREA]); } else { return $response->withStatus(301)->withHeader('Location', '/' . self::AREA . '/auth'); } }