Skip to content

Instantly share code, notes, and snippets.

@wf9a5m75
Created March 10, 2016 17:41
Show Gist options
  • Save wf9a5m75/14928592ce63cf2aafd9 to your computer and use it in GitHub Desktop.
Save wf9a5m75/14928592ce63cf2aafd9 to your computer and use it in GitHub Desktop.
var CLIENT_ID = ""
var CLIENT_SECRET = ""
var REDIRECT_URL = ""
var REFRESH_TOKEN = "";
var async = require('async');
var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
oauth2Client.setCredentials({
refresh_token: REFRESH_TOKEN
});
google.options({ auth: oauth2Client }); // set auth as a global default
var drive = google.drive({ version: 'v2', auth: oauth2Client });
async.waterfall([
function(next) {
drive.files.list(next);
},
function(result, response, next) {
drive.files.get({
fileId: result.items[0].id
}, next);
}
], function(error, result, response) {
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment