Search code examples
directoryauthorizationgoogle-colaboratorydrive

Problem: Google Colab import libraries and authorization to use google drive takes too long?


I execute this part of code in google colab, to authorize me so to get access to my drive folders

!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}

But when it comes to the part of copy and paste the verification code from the given url, execution doesn't end, so to move on the next block. What is the problem?even though I am still connected.


Solution

  • Recently I made a new effort and seems to work, in order to mount your drive to the colab-notebook use these lines instead,

    from google.colab import drive
    drive.mount('/content/gdrive')
    

    Run it,

    Click on the link accept and copy-paste the given code, hit enter done! Much simpler from the previous way I've asked about which by the way it still not working.