public function __construct($settings = array()) { if (!isset($settings['clientId'])) { throw new BackupException('clientId not provided'); } if (!isset($settings['clientSecret'])) { throw new BackupException('clientSecret not provided'); } if (isset($settings['accessTokenLocation'])) { $this->accessTokenLocation = $settings['accessTokenLocation']; } if (isset($settings['refreshTokenLocation'])) { $this->refreshTokenLocation = $settings['refreshTokenLocation']; } $googleHelper = new GoogleHelper($settings['clientId'], $settings['clientSecret']); $this->filesHelper = new FilesHelper($googleHelper); if (file_exists($this->accessTokenLocation)) { $googleHelper->setAccessToken(file_get_contents($this->accessTokenLocation)); } if (file_exists($this->refreshTokenLocation)) { $googleHelper->setRefreshToken(file_get_contents($this->refreshTokenLocation)); } $googleHelper->auth(GoogleHelper::AUTH_TYPE_CMD_LINE); // Save access and refresh tokens file_put_contents($this->accessTokenLocation, $googleHelper->getAccessToken()); file_put_contents($this->refreshTokenLocation, $googleHelper->getRefreshToken()); $this->baseFolder = $this->filesHelper->getFolderByName($this->baseFolderName, false, null, true); }