Installation#

To install gdrive:

$ wget -O gdrive https://docs.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA
$ chmod +x gdrive

Authentication#

By default the Google Drive authentication token will be stored in $HOME/.gdrive. If that location is inaccessible, a different location can be specified with GDRIVE_CONFIG_DIR environment variable.

To authenticate to Google Drive:

$ ./gdrive about
Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=...&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state

Enter verification code:

It will store the token in ~/.gdrive/token_v2.json. If authentication failed, try removing the old ~/.gdrive/token_v2.json.

See also Service Account.

Listing Files and Folders#

To list files and folders:

$ ./gdrive list [-q <query>] [--order <order>]

For example:

$ gdrive list -q "name = 'Backup'"

See also:

Downloading a File#

To download a file:

$ ./gdrive download <file ID>

Uploading a File#

$ ./gdrive upload -p <parent ID> <file>

See Also#