googlecolab / colabtools

Python libraries for Google Colaboratory
Apache License 2.0
2.19k stars 720 forks source link

Unable to connect to Google Drive starting 2022-01-21 #2563

Closed anand-bhat closed 2 years ago

anand-bhat commented 2 years ago

Describe the current behavior Starting 2022-01-21 (this morning), I've been unable to connect Google Drive to a Colab notebook. Using drive._mount() does not launch a new window for authorising access causing ValueError: mount failed: invalid oauth code. This was working previously. image

Using drive.mount() does pop up a window however the auth token doesn't appear to be propagated to Colab resulting in MessageError: Error: credential propagation was unsuccessful image

Describe the expected behavior Should be able to connect to Google Drive from Colab.

What web browser you are using Chrome Version 97.0.4692.99 (Official Build) (64-bit) - All extensions disabled (except a password manager).

Additional context Link to a minimal, public, self-contained notebook that reproduces this issue.

craigcitro commented 2 years ago

To confirm: are you trying to use different google accounts for Colab and connecting to Drive?

This has been supported in the past, but unfortunately no longer is.

anand-bhat commented 2 years ago

I've tried both -- using the same account for Colab and Drive as well as a different ones.

craigcitro commented 2 years ago

Can I ask you to file feedback in-product? (Help -> Send feedback)

craigcitro commented 2 years ago

Also, another question: does it work if you try from a fresh notebook and use a single account from the get-go?

anand-bhat commented 2 years ago

Can I ask you to file feedback in-product? (Help -> Send feedback)

Done.

Also, another question: does it work if you try from a fresh notebook and use a single account from the get-go?

Using drive.mount() worked when using a single account in a new private session! Using a different account for the Drive doesn't work and using _mount() doesn't launch a new window.

I'll create a new browser profile and use a single account to get Drive connected to the notebook. Thanks for the suggestion.!

GHBTM commented 2 years ago

I'm having an identical issue since this morning, 2022-01-21, too. I'm using Colab Pro + and connecting to my own google drive. Both are of the same account. I was able to trigger the authorization link and auth code, as well as the input box using an additional line of code:

from google.colab import drive, auth, output auth.authenticate_user() drive._mount('/content/drive')

However, this works once, throws an error "ValueError: mount failed: invalid oauth code", and then on rerunning the code fails to load the launch link, window, input box, as described above. I've tried playing around with all possible combination of force_remount, use_metadata_server, and ephemeral boolean arguments.

I had at one point cleared the DNS cache, I've revoked privileges (after running the auth.authenticate_user() and oauth dance, despite the ValueError message, seen them reappear in my console), I've logged out of my google account and restarted browser, none of which provided a solution.

RajdeepBorgohain commented 2 years ago

Use this code:

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools !add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null !apt-get update -qq 2>&1 > /dev/null !apt-get -y install -qq google-drive-ocamlfuse fuse from google.colab import auth auth.authenticate_user() from oauth2client.client import GoogleCredentials creds = GoogleCredentials.get_application_default() import getpass !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL vcode = getpass.getpass() !echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} %cd /content !mkdir drive %cd drive !mkdir MyDrive %cd .. %cd .. !google-drive-ocamlfuse /content/drive/MyDrive

Thanks to @zechenli03

alixTal commented 2 years ago

having the same issue since morning, using drive._mount('/drive) give me the mount failed: invalid oauth code error before even showing the google auth link. I have all of my files on my Gsuite account (because it's has a lot more storage), and all my notebooks on my personal account.

qkum commented 2 years ago

Same here, with connecting to the account's own gdrive. Pro+ user.

drive.mount()

Deleting cookies did nothing.

I will check if it is my other Colab tabs logged into another google account (free) that triggers the "anti-free GPU abuse" work you guys got going on.

Update: Incognito Window changed nothing.

GHBTM commented 2 years ago

@zechenli03's answer reposted by RajdeepBorgohain worked! This after about 8 hours trial and error, thank you! Only item to note, old method of drive.mount() or drive._mount created a 'My Drive' folder ('My\ Drive'), with the solution code removing the space ('MyDrive').

cperry-goog commented 2 years ago

Duping all Drive-related activity into this bug for a general update.

There are 3 main issues:

1) There's a legitimate bug which exposed a set of checkboxes to accept OAuth scopes. That is fixed and being rolled out today. 2) Don't use drive._mount(), it's a non-public API and not guaranteed to do what you expect. 3) We've rolled out a new, more secure method to mount Google Drive. This requires using the same account to mount Google Drive as you use for notebook code execution.

If you can reproduce a Drive mount issue after doing the following, please send feedback:

Onkar-2803 commented 2 years ago

To confirm: are you trying to use different google accounts for Colab and connecting to Drive?

This has been supported in the past, but unfortunately no longer is.

Why did they remove this :\

reachrishav commented 2 years ago

@zechenli03's answer reposted by RajdeepBorgohain worked! This after about 8 hours trial and error, thank you! Only item to note, old method of drive.mount() or drive._mount created a 'My Drive' folder ('My\ Drive'), with the solution code removing the space ('MyDrive').

I cant access my shared drives using this. Can you please help? @RajdeepBorgohain @GHBTM

GHBTM commented 2 years ago

My drive, I do not believe it was shared, so I cannot confirm this will work, but this was RajdeepBorgohain' solution that worked for me. @reachrishav have you tried:

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools !add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null !apt-get update -qq 2>&1 > /dev/null !apt-get -y install -qq google-drive-ocamlfuse fuse from google.colab import auth auth.authenticate_user() from oauth2client.client import GoogleCredentials creds = GoogleCredentials.get_application_default() import getpass !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL vcode = getpass.getpass() !echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} %cd /content !mkdir drive %cd drive !mkdir MyDrive %cd .. %cd .. !google-drive-ocamlfuse /content/drive/MyDrive

reachrishav commented 2 years ago

@GHBTM @RajdeepBorgohain Mounting MyDrive seems to work fine. But I am having troubles accessing my shared drives(aka team drives) Is there a similar method to mount the same?

yangfanliang commented 2 years ago

My drive, I do not believe it was shared, so I cannot confirm this will work, but this was RajdeepBorgohain' solution that worked for me. @reachrishav have you tried:

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools !add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null !apt-get update -qq 2>&1 > /dev/null !apt-get -y install -qq google-drive-ocamlfuse fuse from google.colab import auth auth.authenticate_user() from oauth2client.client import GoogleCredentials creds = GoogleCredentials.get_application_default() import getpass !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL vcode = getpass.getpass() !echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} %cd /content !mkdir drive %cd drive !mkdir MyDrive %cd .. %cd .. !google-drive-ocamlfuse /content/drive/MyDrive

I think this workaround no longer works starting today...

Digital-XxX commented 2 years ago

My drive, I do not believe it was shared, so I cannot confirm this will work, but this was RajdeepBorgohain' solution that worked for me. @reachrishav have you tried: !apt-get install -y -qq software-properties-common python-software-properties module-init-tools !add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null !apt-get update -qq 2>&1 > /dev/null !apt-get -y install -qq google-drive-ocamlfuse fuse from google.colab import auth auth.authenticate_user() from oauth2client.client import GoogleCredentials creds = GoogleCredentials.get_application_default() import getpass !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL vcode = getpass.getpass() !echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} %cd /content !mkdir drive %cd drive !mkdir MyDrive %cd .. %cd .. !google-drive-ocamlfuse /content/drive/MyDrive

I think this workaround no longer works starting today...

Is there a new method to mount gdrive?