protected function loadAccessTokenByAuthenticatingUser(callable $getAuthCode)
    {
        // Getting an auth code
        try {
            $authUrl = $this->client->createAuthUrl();
        } catch (\Exception $exception) {
            throw new \RuntimeException(
                'Couldn\'t create an authentication URL: '.rtrim($exception->getMessage(), '.').'. ' .
                'Maybe there is a problem with the secret file.'
            );
        }

        $authCode = $getAuthCode($authUrl);
        if (!is_string($authCode) || $authCode === '') {
            throw new \LogicException('The $getAuthCode function has returned a not-string or an empty string');
        }

        // Authenticating
        $this->logger->info('Sending the authentication code to Google');
        try {
            $accessToken = $this->client->fetchAccessTokenWithAuthCode($authCode);
        } catch (\Exception $exception) {
            throw new \RuntimeException(
                'Failed to send the authentication code to Google: '.rtrim($exception->getMessage(), '.').'. ' .
                'Maybe there is a problem with the secret file.'
            );
        }
        if (isset($accessToken['error'])) {
            throw new \RuntimeException('Google has declined the auth code: '.($accessToken['error_description'] ?? '(no message)'));
        }

        $this->logger->notice('Authenticated successfully');
    }