Google drive authentication timeout

Hi,

I’m trying to add a Google Drive folder as remote. I followed the instructions in the corresponding docs, but after authenticating (when running dvc push) the browser window opens, I check all permission boxes, continue and get the message “The authentication flow has completed.”… and nothing happens.

dvc in the terminal ends up exiting with “authentication time-out”, and the credentials file is not created (I looked for it in the $CACHE_DIR/pydrive2fs/....apps.googleusercontent.com folder. The folder exists, but it’s empty).

I tried this with my personal google account, and also a service account. The result is the same, I get to the authentication page, give permissions and nothing happens.

I tried installing dvc in different ways, homebrew, pipx, and straight into my venv, but nothing worked.

I also tried different browsers, I use Arc, but tested on chrome and safari and got the same results.

Here’s the output to dvc push -r drive -v

> dvc push -r drive -v  
                                                                                                                                                                                              
2024-03-24 19:15:54,198 DEBUG: v3.48.4 (pip), CPython 3.11.3 on macOS-14.4-x86_64-i386-64bit
2024-03-24 19:15:54,198 DEBUG: command: /Users/german/.pyenv/versions/austral-image-preprocessing/bin/dvc push -r drive -v
Collecting                                                                                                                                                                                     |0.00 [00:00,    ?entry/s]
2024-03-24 19:15:55,141 DEBUG: Preparing to transfer data from '/Users/german/code/austral/tesis-austral/model-division-classifier/.dvc/cache/files/md5' to 'gdrive://14QlxNb8h2RyHyFZKTEO9O9dN4IgtPsqI/files/md5'
2024-03-24 19:15:55,141 DEBUG: Preparing to collect status from '14QlxNb8h2RyHyFZKTEO9O9dN4IgtPsqI/files/md5'
2024-03-24 19:15:55,151 DEBUG: Collecting status from '14QlxNb8h2RyHyFZKTEO9O9dN4IgtPsqI/files/md5'
2024-03-24 19:15:55,153 DEBUG: Querying 1 oids via object_exists
Pushing                                                                                                                                                                                                                 /Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access /Users/german/Library/Caches/pydrive2fs/276097357287-omnner099v57gkpvu0nvbomlv9iq1426.apps.googleusercontent.com/default.json: No such file or directory
  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?client_id=276097357287-omnner099v57gkpvu0nvbomlv9iq1426.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.appdata&access_type=offline&response_type=code&approval_prompt=force

Pushing
2024-03-24 19:17:26,554 ERROR: unexpected error - Failed to authenticate GDrive: [Errno 60] Operation timed out                                                                                                          
Traceback (most recent call last):
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/pydrive2/fs/spec.py", line 70, in _wrap_errors
    yield
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/pydrive2/fs/spec.py", line 127, in _client_auth
    auth.LocalWebserverAuth()
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/pydrive2/auth.py", line 137, in _decorated
    self.Auth(code)
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/pydrive2/auth.py", line 702, in Auth
    self.Authenticate(code)
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/pydrive2/auth.py", line 715, in Authenticate
    self.credentials = self.flow.step2_exchange(code)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/oauth2client/client.py", line 2053, in step2_exchange
    resp, content = transport.request(
                    ^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/oauth2client/transport.py", line 280, in request
    return http_callable(uri, method=method, body=body, headers=headers,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/httplib2/__init__.py", line 1724, in request
    (response, content) = self._request(
                          ^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/httplib2/__init__.py", line 1444, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/httplib2/__init__.py", line 1366, in _conn_request
    conn.connect()
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/httplib2/__init__.py", line 1156, in connect
    sock.connect((self.host, self.port))
TimeoutError: [Errno 60] Operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc/cli/__init__.py", line 211, in main
    ret = cmd.do_run()
          ^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc/cli/command.py", line 27, in do_run
    return self.run()
           ^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc/commands/data_sync.py", line 64, in run
    processed_files_count = self.repo.push(
                            ^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc/repo/__init__.py", line 58, in wrapper
    return f(repo, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc/repo/push.py", line 140, in push
    push_transferred, push_failed = ipush(
                                    ^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc_data/index/push.py", line 76, in push
    result = transfer(
             ^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc_data/hashfile/transfer.py", line 203, in transfer
    status = compare_status(
             ^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc_data/hashfile/status.py", line 179, in compare_status
    dest_exists, dest_missing = status(
                                ^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc_data/hashfile/status.py", line 139, in status
    exists = hashes.intersection(
             ^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc_data/hashfile/status.py", line 59, in _indexed_dir_hashes
    dir_exists.update(
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/tqdm/std.py", line 1181, in __iter__
    for obj in iterable:
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc_objects/db.py", line 366, in list_oids_exists
    in_remote = self.fs.exists(paths, batch_size=jobs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc_objects/fs/base.py", line 454, in exists
    if self.fs.async_impl:
       ^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/funcy/objects.py", line 47, in __get__
    return prop.__get__(instance, type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/funcy/objects.py", line 25, in __get__
    res = instance.__dict__[self.fget.__name__] = self.fget(instance)
                                                  ^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/dvc_gdrive/__init__.py", line 106, in fs
    return _GDriveFileSystem(self._path, **self._settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/fsspec/spec.py", line 80, in __call__
    obj = super().__call__(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/pydrive2/fs/spec.py", line 226, in __init__
    google_auth = _client_auth(
                  ^^^^^^^^^^^^^
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/pydrive2/fs/spec.py", line 126, in _client_auth
    with _wrap_errors():
  File "/Users/german/.pyenv/versions/3.11.3/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/german/.pyenv/versions/3.11.3/envs/austral-image-preprocessing/lib/python3.11/site-packages/pydrive2/fs/spec.py", line 76, in _wrap_errors
    raise GDriveAuthError("Failed to authenticate GDrive") from exc
pydrive2.fs.spec.GDriveAuthError: Failed to authenticate GDrive

2024-03-24 19:17:26,594 DEBUG: Removing '/Users/german/code/austral/tesis-austral/.OJ58tbESwKb5FytdihWu_Q.tmp'
2024-03-24 19:17:26,594 DEBUG: Removing '/Users/german/code/austral/tesis-austral/.OJ58tbESwKb5FytdihWu_Q.tmp'
2024-03-24 19:17:26,595 DEBUG: Removing '/Users/german/code/austral/tesis-austral/.OJ58tbESwKb5FytdihWu_Q.tmp'
2024-03-24 19:17:26,595 DEBUG: Removing '/Users/german/code/austral/tesis-austral/model-division-classifier/.dvc/cache/files/md5/.k2YqavGPg87AHez4_YTbqw.tmp'
2024-03-24 19:17:26,597 DEBUG: Version info for developers:
DVC version: 3.48.4 (pip)
-------------------------
Platform: Python 3.11.3 on macOS-14.4-x86_64-i386-64bit
Subprojects:
	dvc_data = 3.14.1
	dvc_objects = 5.1.0
	dvc_render = 1.0.1
	dvc_task = 0.3.0
	scmrepo = 3.3.1
Supports:
	gdrive (pydrive2 = 1.19.0),
	http (aiohttp = 3.9.3, aiohttp-retry = 2.8.3),
	https (aiohttp = 3.9.3, aiohttp-retry = 2.8.3),
	s3 (s3fs = 2024.3.1, boto3 = 1.34.51)
Config:
	Global: /Users/german/Library/Application Support/dvc
	System: /Library/Application Support/dvc
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk1s7s1
Caches: local
Remotes: s3, gdrive
Workspace directory: apfs on /dev/disk1s7s1
Repo: dvc, git
Repo.site_cache_dir: /Library/Caches/dvc/repo/f4c807140ee0e0c94be9bfbcc8a916ad

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
2024-03-24 19:17:26,599 DEBUG: Analytics is enabled.
2024-03-24 19:17:26,671 DEBUG: Trying to spawn ['daemon', 'analytics', '/var/folders/05/m59g6w9s1b52ff5yh3cl2qth0000gn/T/tmpa88nafts', '-v']
2024-03-24 19:17:26,683 DEBUG: Spawned ['daemon', 'analytics', '/var/folders/05/m59g6w9s1b52ff5yh3cl2qth0000gn/T/tmpa88nafts', '-v'] with pid 70304

Any help will be much appreciated!

Thanks