public function authenticateFromCommand(
        InputInterface $input,
        OutputInterface $output,
        string $gApiOAuthSecretFile,
        ?string $gApiAccessTokenFile,
        array $scopes,
        bool $forceAuthenticate = false
    ): bool {
        try {
            $this->authenticate(
                $gApiOAuthSecretFile,
                $gApiAccessTokenFile,
                $scopes,
                function ($authURL) use ($input, $output) {
                    $output->writeln('<info>You need to authenticate to your Google account to proceed</info>');
                    $output->writeln('Open the following URL in a browser, get an auth code and paste it below:');
                    $output->writeln('');
                    $output->writeln($authURL, OutputInterface::OUTPUT_PLAIN);
                    $output->writeln('');

                    $question = new Question('Auth code: ');
                    $question->setValidator(function ($answer) {
                        $answer = trim($answer);

                        if ($answer === '') {
                            throw new \RuntimeException('Please enter an auth code');
                        }

                        return $answer;
                    });
                    return (new QuestionHelper())->ask($input, $output, $question);
                },
                $forceAuthenticate
            );
        } catch (\RuntimeException $exception) {
            $output->writeln('<error>Failed to authenticate to Google: '.OutputFormatter::escape($exception->getMessage()).'</error>');
            return false;
        }

        return true;
    }