public function authenticate(
        string $gApiOAuthSecretFile,
        ?string $gApiAccessTokenFile,
        array $scopes,
        callable $getAuthCode,
        bool $forceAuthenticate = false
    ) {
        $this->client->setApplicationName('XmlSquad Tools');
        $this->client->setScopes($scopes);
        $this->client->setAccessType('offline');
        $this->client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
        $this->loadClientSecretFromFile($gApiOAuthSecretFile);

        // Getting an access token
        if ($gApiAccessTokenFile !== null && !$forceAuthenticate && is_file($gApiAccessTokenFile)) {
            $this->loadAccessTokenFromFile($gApiAccessTokenFile);
        } else {
            $this->loadAccessTokenByAuthenticatingUser($getAuthCode);

            if ($gApiAccessTokenFile !== null) {
                $this->saveCurrentAccessTokenToFile($gApiAccessTokenFile);
                $this->logger->info('So subsequent executions will not prompt for authorization');
            }
        }

        if ($this->refreshAccessTokenIfRequired()) {
            if ($gApiAccessTokenFile !== null) {
                $this->saveCurrentAccessTokenToFile($gApiAccessTokenFile);
            }
        }

        $this->logger->info('The Google authentication is completed');
    }