3
$\begingroup$

I have recently discovered Google Colab and I am wondering if there is an option to permanently authorize Google Colab to access and mount my Google Drive.

from google.colab import drive
drive.mount('/content/drive')
Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=xxx
Enter your authorization code:
··········
Mounted at /content/drive

Right now, I need to all the time insert manually the authorization code and I want when I start a new Google Colab to have my drive mounted.

Is there an option to do that or I should execute this all the time manually?

$\endgroup$
2
$\begingroup$

For some reason, Colab allows me to automatically mount if I'm the creator of the notebook. If that's not the case, such was when I create a copy, the from google.colab import drive code block automatically gets added, and I have to authorize again.

File > New notebook

Then navigate to the file browser. Click on "Mount Drive".

From then on, every time I connect, it automatically mounts Drive during the Initializing phase.

| improve this answer | |
$\endgroup$
2
$\begingroup$

I was working on a google colab project, after a while I decided to copy the work and rename it as a new version (manual type of git control). After doing this I noticed that my google drive doesn't automatically mount. After checking some of the settings I went to File > Update Drive Preview after doing this, the google drive is automatically added when restarting the notebook. Even when commenting out these lines...

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

Hope this helps

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.