Since yesterday I have had the problem that I can no longer mount my Google account. Normally, when I run it, I get a link to authorize myself with. Now, when the code is executed, an extra browser window is opened where I should authorize myself. But if I do it over it, it doesn't work. Do you know why it can be that this authorization link is suddenly no longer shown? Any security setting maybe? I've tried several browsers.
EDIT: With the new authorization popup it works if i mount the google drive from the same google account like colab. But the problem is that my main google drive is on another account than Google Colab. With the link it used to work without any problems earlier...
EDIT 2: I have now solved it in such a way that I have shared the required folder for my other account and can now access it via my Colab Google Drive account. But I still didn't manage to get the link back.
After the code execution and authorization with the new popup i get this error message on Google Colab:
MessageError Traceback (most recent call last) in () 1 #Connect Google Drive 2 from google.colab import drive ----> 3 drive.mount('/gdrive')
3 frames /usr/local/lib/python3.7/dist-packages/google/colab/_message.py in read_reply_from_input(message_id, timeout_sec) 104 reply.get('colab_msg_id') == message_id): 105 if 'error' in reply: --> 106 raise MessageError(reply['error']) 107 return reply.get('data', None) 108
MessageError: Error: credential propagation was unsuccessful
I use this code:
#Connect Google Drive
from google.colab import drive
drive.mount('/gdrive')
Authorization popup instead of the link in the code output
Accessing Google Drive from Google ColabOnce the Drive is mounted, you'll get the message “Mounted at /content/gdrive” , and you'll be able to browse through the contents of your Drive from the file-explorer pane. Now you can interact with your Google Drive as if it was a folder in your Colab environment.
Update: Unfortunately, From Jan 20, 2022, The small solution based on Blue's solution and the similar solutions isn't working anymore (Reference). You can use my old solution again...
Update2: From Mars 30, 2022, my old solution isn't working too! I find another solution (Phillip's solution) that is working now.
Phillip's Solution:
This solution is based on Phillip's post. You can follow his post for more information.
Follow these steps:
!sudo add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!sudo apt-get update -qq 2>&1 > /dev/null
!sudo apt -y install -qq google-drive-ocamlfuse 2>&1 > /dev/null
!google-drive-ocamlfuse
Failure("Error opening URL:https://accounts.google.com/o/oauth2/auth?client_id=... ")
!sudo apt-get install -qq w3m # to act as web browser
!xdg-settings set default-web-browser w3m.desktop # to set default browser
%cd /content
!mkdir drive
%cd drive
!mkdir MyDrive
%cd ..
%cd ..
!google-drive-ocamlfuse /content/drive/MyDrive
You must get this message:
Access token retrieved correctly.
My Old Solution
!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
Blue's Solution
from google.colab import drive
drive._mount('/content/drive')
[Edit] This is not working anymore as google has removed this feature. https://github.com/googlecolab/colabtools/issues/2562#issuecomment-1017869732
I have this issue also. But this solve the issue. (There is a underscore before mount
)
from google.colab import drive
drive._mount('/content/drive')
It is due to the new policy. If your acc mounted is different Colab acc, please use the syntax to make it work.
from google.colab import drive
drive._mount('/content/drive')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With