To facilitate updating of content on our information screen, we are looking at putting the content on Google Drive and then allowing the content to be synced via a NodeJS based application.
At the moment I am trying to test this approach using folder shared from my own account.
What I have so far, based on the documentation at https://github.com/google/google-api-nodejs-client/tree/master :
var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var readline = require('readline');
const CLIENT_ID = 'xxxxxxxx.apps.googleusercontent.com';
const CLIENT_SECRET = '7h3c13n7s3cr37';
const REDIRECT_URL = 'https://accounts.google.com/o/oauth2/auth';
var oauth2Client = new OAuth2(
CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
var scopes = [
'https://www.googleapis.com/auth/drive.readonly',
'https://www.googleapis.com/auth/drive.metadata.readonly'
];
var url = oauth2Client.generateAuthUrl({
access_type: 'offline', // 'online' (default) or 'offline' (gets refresh_token)
scope: scopes // If you only need one scope you can pass it as string
});
console.log('past following URL into a web browser');
console.log(url);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Provide Key generated on web page ', (answer) => {
// store response key in file?
var drive = google.drive({ version: 'v2', auth: oauth2Client });
var folderId = 'mif01d3r';
drive.children.list({
auth: answer,
folderId: folderId,
}, function(error, response) {
if (error) {
console.log('err: ', error);
return;
}
console.log(response);
});
});
The current issue here is that the value for 'REDIRECT_URL' does not seem suitable. What should I be putting here for a command line application?