Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Drive v3 API Samples

These samples allow you to list, download, and upload files from Google Drive.

Running the samples

Note: Node.js version 8 or greater is required to run samples.

Set the following values in oauth2.keys.json (up one directory) under the web key:

  • redirect_uris
  • client_id
  • project_id
  • client_secret

Your file should look like this:

{
  "web" : {
    "redirect_uris": ["http://localhost:3000/oauth2callback"],
    "client_id": "<YOUR_CLIENT_ID>",
    "client_secret": "<YOUR_CLIENT_SECRET>",
    "project_id": "<YOUR_PROJECT_ID>"
  }
}

Run the quickstart.js sample:

This sample will list the files in the user's Google Drive.

You'll need to do the following before you can run this sample:

  • Enable the Google Drive API.
  • Set the redirect API in the Google Cloud Console application registration to http://localhost:3000/oauth2callback.
node quickstart.js

Run the download.js sample:

Run the quickstart.js sample to get a list of files in your Google Drive.

node download.js <fileId>

where <fileId> is the id of any file in Google Drive.

Example:

node download.js 0B_Klegupc5gUcXhFZjZVUV9NeE0

Run the export.js sample:

node export.js <fileId>=

where <fileId> is the id of a Google Doc in Google Drive.

Example:

node export.js 0B_Klegupc5gUcXhFZjZVUV9NeE0 ./file.pdf