Giter Club home page Giter Club logo

gdrive-cli's Introduction

#gdrive-cli

Please see http://tomdignan.com/projects/gdrive-cli for a video introduction.

##Dependencies

sudo pip install google-api-python-client
sudo pip install httplib2

##Chrome Application

I just received word from Ali Afshar on Stack Overflow that this is no longer required! I have yet to test gdrive-cli under these new circumstances, but it probably works without this.

To use this, you need to register a chrome application. It must be at least installable by you, but need not be published. There is a boilerplate app in the repo you can use to base yours off of. I highly encourage you to take this code and use it to work towards developing useful and profitable chrome apps on the chrome web store!

You must publish the chrome app for this to work. It need not be published publically, but you must at least make use of the "publish to test accounts feature" or you will get error 403.

##Installation

  1. Visit http://developers.google.com/drive and perform all the required steps to publish a chrome app with Google Drive enabled. Don't hestitate to contact me if you have trouble with this, because it is tricky.
  2. You must create this chrome app, put it in the chrome web store, and install it in your browser!
  3. git clone https://[email protected]/tom-dignan/gdrive-cli.git
  4. Using the information you got from google, create a $HOME/.gdrive_client_secrets file. Remove the trailing "apps.googleusercontent.com" from the id as well as the prepending word "secret" from the client secret.
  5. ./gdrive-cli --init-database to create your local database. You may remove the ~/.gdrive prefixed files if necessary, but if you remove your client secrets file you should back it up. Removing these files will revoke your ability to list uploaded files permanently, as gdrive-cli relies on a local SQLite database to list files, since files are private to the Google Drive app that creates them. Google Docs supports listings, if you want to write support for that, but I like the speed of local metadata.
  6. ./gdrive-cli --authenticate will open an oauth dialog in your default browser. For official support, you must make chrome your default browser. Click this.
  7. You are ready to issue gdrive-cli commands. Have fun. If your session expires, reauthenticate.

##Setting the default browser

gdrive-cli uses python's webbrowser module to find your default browser. You can set the BROWSER environment variable to override this. For more information, see webbrowser

export BROWSER="google-chrome"

##Client Secrets File

In step 4, you made a client secrets file. This is what it MUST look like:

{
    "web": {
        "client_id" : "_REDACTED_",
        "client_secret": "_REDACTED_",
        "redirect_uris": ["URIsurn:ietf:wg:oauth:2.0:oob", "http://tomdignan.com/projects/gdrive-cli/"],
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://accounts.google.com/o/oauth2/token"
    }
}
  • Your client_id must NOT contain "apps.googleusercontent.com"
  • Your client_secret must not have the word "secret" prepended to it.

Valid places for this file are, in order

  1. $CWD/.private/client_secrets.json
  2. $HOME/.gdrive_client_secrets
  3. /etc/gdrive-cli

##How to upload a file, show its remote metadata, and then download it.

To upload a file you must have enabled its mime type in the Google API console under Google Drive SDK, and filled out all other fields of this form. You must supply the file extension in the title. For now, just use "none" as the parent id. The code will see "none" and ignore the field.

gdrive-cli --insert foo.txt "my foo document" none "text/plain" foo.txt
gdrive-cli --show <hash_that_insert_printed>
gdrive-cli --download <hash_that_insert_printed>

##Listing files

You can list files with

gdrive-cli --list

##FAQ

Q. Can I use this code to make a FUSE filesystem?

A. Yes, use fuse-python. There is currently a C project underway as well that you should check out https://github.com/jcline/fuse-google-drive although I am unsure of the status at this time.

Q. Why am I am getting "The authenticated user has not installed the app with client idโ€ error?

A. Read my answer on Stack Overflow

##Credits

###Patch Contributors

###Packagers

Thanks to

  • Daniel Wallace aka gtmanfred for being the first to install gdrive-cli and creating a package for arch linux's AUR.

##Support

Live support in #gdrive-cli on irc.freenode.net and development discussion! You may have to idle a bit.

##Known Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.