Jyoti yadav
Jyoti yadav

Reputation: 300

Mounting the drive in Google Colab Enterprise

!sudo echo -ne '\n' | sudo add-apt-repository ppa:alessandro-strada/ppa >/dev/null 2>&1 # note: >/dev/null 2>&1 is used to supress printing
!sudo apt update >/dev/null 2>&1
!sudo apt install google-drive-ocamlfuse >/dev/null 2>&1
!google-drive-ocamlfuse
!sudo apt-get install w3m >/dev/null 2>&1 # to act as web browser
!xdg-settings set default-web-browser w3m.desktop >/dev/null 2>&1 # to set default browser
%cd /content
!mkdir gdrive
%cd gdrive
!mkdir "My Drive"
!google-drive-ocamlfuse "/content/gdrive/My Drive"

I am getting the below error.

You should specify a client id (-id) and a client secret (-secret)

Any suggestions how to fix this?

Upvotes: 2

Views: 1687

Answers (2)

gogasca
gogasca

Reputation: 10048

I tried with the following:

google-drive-ocamlfuse -debug -id XXXXX.apps.googleusercontent.com -secret YYYY -port=8081 -cc -headless
Starting application setup (label=default, base_dir=).
[0.000257] TID=0: Loading configuration from /root/.gdfuse/default/config...done
Opening log file: /root/.gdfuse/default/gdfuse.log
Clearing cache...done
Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=XXXXXX.apps.googleusercontent.com&redirect_uri=http%3A%2F%2F127.0.0.1%3A8081%2Foauth2callback&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force
Please enter the verification code: 

Then in the browser you will open a URL. This is because by default when you configure your Client ID, loopback IP addres is used. From URL copy the 'code' parameter. Plug that in.

Note: Does not matter that 127.0.0.1 is not reachable. Page result will be not found, but URL still correct.

Please enter the verification code: ZZZZ
Access token retrieved correctly.

Then run

google-drive-ocamlfuse -debug /content/drive/

(drive folder is empty)

From Terminal you can see your files now.

/content# ls -lh drive/
total 681K
-rw-r--r-- 1 root root 681K Nov 15  2019 'Getting started'
-r--r--r-- 1 root root  149 May 31  2021 'Interview Notes.desktop'

Upvotes: 0

gogasca
gogasca

Reputation: 10048

From README.md

First, you must set up OAuth 2.0:

  1. Activate the Google Drive API.
  2. Create an OAuth client ID.
  3. Choose Desktop as Application type.
  4. Set the Name to anything you like.

This way you will get a Client ID and Client secret that you can use to access your Drive. To authorize google-drive-ocamlfuse, pass the client ID and the client secret on the command line, e.g.:

google-drive-ocamlfuse -id xxxxxxxxxx.apps.googleusercontent.com -secret XXX-YYY-ZZZ

https://github.com/astrada/google-drive-ocamlfuse?tab=readme-ov-file#usage

Upvotes: 0

Related Questions