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:
-
run the gettoken.js, which is written for getting the access tokens:
//gettoken.jsvar 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();var getAccessToken = function(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.jsvar 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));