Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reauthorize DVC with Google Drive for remote storage?

Tags:

dvc

I am using DVC to keep track of my data and steps in my machine learning project. I am trying to setup a remote using google drive. This is not necessarily difficult and i used the documentation from dvc.

I get an error when i try to use dvc push

ERROR: unexpected error - Failed to authenticate GDrive: Access token refresh failed: invalid_grant: Token has been expired or revoked.

The first time i used the command i got redirected to the google drive login page and could give dvc permission to edit files. I think i forgot to give it the right permissions but if i now rerun the command i do not get send to the login page. Does anyone know how to get the login again to google drive and give the right permissions to dvc.

I already tried completly removing everything related to dvc from my project but this did not seem to help

like image 592
Levino Avatar asked Sep 17 '25 12:09

Levino


1 Answers

What are looking for is described on the Google Drive for DVC page under the gdrive_user_credentials_file option.

Namely, the default is $CACHE_HOME/pydrive2fs/{gdrive_client_id}/default.json (unless profile is specified), where the CACHE_HOME location per platform is:

macOS Linux (*typical) Windows
~/Library/Caches ~/.cache %CSIDL_LOCAL_APPDATA%

You should be able to drop the file and run dvc pull, dvc push (or any other DVC command that would actually involve DVC accessing the remote storage) to generate the file again.

If it happens often, you can use the very same option drive_user_credentials_file to customize the location for this file.

$ dvc remote modify myremote \
      gdrive_user_credentials_file path/to/mycredentials.json

Here is the related discussion on why the refresh token expires. There are options (service account with delegation, or publishing an app to make the refresh token more permanent, use the built-in DVC app for now). They all have certain benefits and downsides. Please chime in the ticket or here to discuss them.

like image 112
Shcheklein Avatar answered Sep 19 '25 02:09

Shcheklein