dvc: wrong redirection when dvc push to gdrive and no verification code is shown

Bug Report

I have already set-up my gdrive FOLDER_ID accroding to the DVC document. However, the line for Enter verification code: did not show. When I pasted the link to the browser authorized it, and click the continuing button, the browser redirect to localhost:8080?code=... and no verification code is shown.

The issue is about DVC version 2.13.0. Everything looks fine after I downgraded my DVC version to 2.11.0.

Reproduce

  1. $ dvc add data
  2. $ dvc remote add -d ${REMOTE_NAME} gdrive://${FOLDER_ID}
  3. $ dvc push

Expected

Enter verification code: should be shown and the browser should redirect to the corresponding verification code.

Environment information

DVC version 2.13.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

I am having the same issue as @shakraz, when I try to use DVC commands related to the Google Drive on my ssh server. It is behind the OpenVPN and I assume, that this may cause this issue.

The only fix that works is the one suggested by @Min-Sheng here:

I think I find the problem. It is about port forwarding! Because I run DVC on my remote server via SSH, I need to forward my localhost 8080 port to remote server 8080 port.

In my case with the OpenVPN the command is:

ssh -L 8080:localhost:8080 your-username@your-remote-name

@efiop My suggestion is that maybe making the old authorization method (with copying the code from the browser to the terminal) available again would be enough as a quick-fix. It may be enabled via an optional parameter. This would be sufficient in most vpn-based scenarios as the user would paste the code to the terminal with the open ssh session, which would be already behind the VPN.

For the record, docs are a bit outdated - I’ve created a PR - https://github.com/iterative/dvc.org/pull/3821/files

It doesn’t to Enter verification code now, it get’s from the browser since via web server that it creates.

Do you see the Authentication successful.?

@Min-Sheng So it is solved for you now?

Btw, to avoid port forwarding you might want to use a service account as noted in the docs. https://dvc.org/doc/user-guide/setup-google-drive-remote#setup-a-google-drive-dvc-remote @efiop Yes, I solved it with port forwarding.

Hey @Min-Sheng 😃 What error did you get? Did dvc push not work at all? Could you show full output of dvc push -v, please?

Hi @efiop and @shcheklein. Thanks for your concern!

For DVC version 2.13.0

  0% Checking cache in '1-736e5qemsLRdaGFbxiW_1pcfApwVXZH'|                                                                                                                                               |0/? [00:00<?,    ?files/s]Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?client_id=710796635688-iivsgbgsb6uv1fap6635dhvuei09o66c.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

截圖 2022-07-29 上午10 45 47

But after I authorize, it redirect to this url: http://localhost:8080/?code=4/0AdQt8qgV8SAXduPyDDgMexBuWbU61HsL8T0vFoPdS4UpGLVBnEx6-oTae10pkd7dY94fMQ&scope=https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.appdata

For DVC version 2.15.0, I got the error:

ERROR: unexpected error - __init__() missing 1 required positional argument: 'google_auth'

@xihajun Sorry for a late response. As long as you update dvc along with corresponding pydrive2 version (e.g. make sure pip check is not complaining) - it should work fine.

@shakraz Please share more details about the error you are getting. There has been multiple things discussed in this ticket with different workaround solutions.

Thanks for all of this. May I kindly ask if we went back to version 2.11.0, will we still have the same issue?

I think I find the problem. It is about port forwarding! Because I run DVC on my remote server via SSH, I need to forward my localhost 8080 port to remote server 8080 port.