/** * Redirecting to: https://accounts.google.com/o/oauth2/auth? * response_type=code * &redirect_uri=[callback_address] * &scope=https://www.googleapis.com/auth/drive.readonly * &client_id=[client_id] * &access_type=online * &include_granted_scopes=true * * @param Request $request * @param Response $response * @return mixed */ public function authenticate(Request $request, Response $response) { $responseUrl = $this->helper->getCallbackUrl(self::AREA); $config = $this->config; // dereference for PHPStorm bug $params = ['response_type' => 'code', 'redirect_uri' => $responseUrl, 'scope' => $config::SCOPE, 'client_id' => $this->config->getClientId(), 'access_type' => 'online', 'include_granted_scopes' => 'true']; $url = $this->config->getAuthUri() . '?' . http_build_query($params); return $response->withStatus(301)->withHeader('Location', $url); }