authenticationgoogle-drive-apipopupgoogle-colaboratorymount

Why can't Google Drive be mounted anymore and shows a browser popup instead of a link for authorization?


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.

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.

After the code execution and authorization with the new popup, I get this error message on Google Colab:

MessageError
Traceback (most recent call last)
<ipython-input-3-897b42bdb537> in <module>()
     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:

Why is the authorization link suddenly no longer shown? Any security setting, maybe? I've tried several browsers.


Solution

  • Disclaimer: As of March 30, 2022, this solution isn't working anymore.


    !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