###How to use:
-
Make sure you have a google account, and you should create a project in https://console.developers.google.com/.
-
Enter your project's console homepage, and go into APIs & auth -> Credentials, then add a credentials for your project.
-
set your Authorized JavaScript origins.
-
set your Authorized redirect URIs, this url should be put info config.json with Key REDIRECT_URL.
-
create a config.json locally, just like below:
{ "CLIENT_ID": "your CLIENT_ID", "CLIENT_SECRET": "your CLIENT_ID", "REDIRECT_URL": "http://localhost:80/oauth2callback", "SCOPE": "https://www.googleapis.com/auth/drive" }
-
run the gettoken.js, which is written for getting the access tokens:
//gettoken.js var readline = require('readline'); var config = require('./config'); var gdrive = require('gdrive'); var auth = gdrive.createAuthObj(config); var url = gdrive.generateAuthUrl(auth, config); console.log('----copy the url below, and access it by browser:\n\n' + url); var rl = readline.createInterface({ input: process.stdin, output: process.stdout }); var getAccessToken = function(code) { common.getToken(auth, code); }; rl.question('\n\n----Enter the code here:\n\n', getAccessToken);
-
run the getfileinfo.js, which is written for getting the files info from google drive:
//getfileinfo.js var config = require('./config'); var token = require('./token'); var gdrive = require('gdrive'); query = "title != '' "; var auth = gdrive.createAuthObj(config, token); gdrive.QueryFile(auth, query, function(files) { gdrive.PrintFilesInfo(files); });