Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.plus.people.get({ userId: userId })
.withAuthClient(authClient)
.execute(callback);
}
function printUserProfile(err, profile) {
if (err) {
console.log('An error occurred');
} else {
console.log(profile.displayName, ':', profile.tagline);
console.log(profile)
}
}
// load google plus v1 API resources and methods
googleapis
.discover('plus', 'v1')
.execute(function(err, client) {
var oauth2Client =
new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
// retrieve an access token
getAccessToken(oauth2Client, function() {
// retrieve user profile
getUserProfile(
client, oauth2Client, 'me', printUserProfile);
});
});
var OAuth2Client = googleapis.OAuth2Client;
// Client ID and client secret are available at
// https://code.google.com/apis/console
var CLIENT_ID = '998322373435.apps.googleusercontent.com';
var CLIENT_SECRET = 'U8QgUx2ygHzI-n5txUPMgcYV';
var REDIRECT_URL = 'http://localhost/oauth2callback';
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// load google plus v1 API resources and methods
googleapis
.discover('plus', 'v1')
.execute(function(err, client) {
var oauth2Client =
new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
console.dir(oauth2Client);
// generate consent page url
var url = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: 'https://www.googleapis.com/auth/plus.me'
});
console.log('Visit the url: ', url)
var gotToken = function () {
googleapis
.discover('mirror', 'v1')
.execute(function (err, client) {
if (!!err) {
failure();
return;
}
console.log('mirror client', client);
listTimeline(client, failure, success);
insertHello(client, failure, success);
insertContact(client, failure, success);
insertLocation(client, failure, success);
getLocation(client, failure, success);
});
};
function deleteFile (file, request, response, next, cbk) {
oauth2Client.credentials = request.session.gdrive_token;
googleapis
.discover('drive', 'v2')
.execute(function(err, client) {
if (err){
var errCode = null;
if (err.code){
errCode = err.code;
}
cbk ({success:false, code:errCode});
return;
}
try{
client
.drive.files.delete({"fileId":file.id})
.withAuthClient(oauth2Client)
.execute(function (a, b, c) {
console.warn("File deleted "+file.title);
function moveFile (src_file, dst_file_data, request, response, next, cbk) {
oauth2Client.credentials = request.session.gdrive_token;
googleapis
.discover('drive', 'v2')
.execute(function(err, client) {
if (err){
var errCode = null;
if (err.code){
errCode = err.code;
}
cbk ({success:false, code:errCode});
return;
}
try{
client
.drive.files.update({'fileId': src_file.id, 'resource': dst_file_data})
.withAuthClient(oauth2Client)
.execute(function (a, file_data, c) {
console.warn("File moved ");
function copyFile (src_file, dst_file_data, request, response, next, cbk) {
oauth2Client.credentials = request.session.gdrive_token;
googleapis
.discover('drive', 'v2')
.execute(function(err, client) {
if (err){
var errCode = null;
if (err.code){
errCode = err.code;
}
cbk ({success:false, code:errCode});
return;
}
try{
client
.drive.files.copy({'fileId': src_file.id, 'resource': dst_file_data})
.withAuthClient(oauth2Client)
.execute(function (a, file_data, c) {
console.warn("File copyed ");
_loadDriveIfRequired: function(callback) {
if (!client) {
googleapis.discover('drive', 'v2').execute(function(err, c) {
client = c;
callback();
});
} else {
callback();
}
},
generateAuthUrl: function() {
function getFile (file, request, response, next, cbk) {
oauth2Client.credentials = request.session.gdrive_token;
googleapis
.discover('drive', 'v2')
.execute(function(err, client) {
if (err){
var errCode = null;
if (err.code){
errCode = err.code;
}
cbk ({success:false, code:errCode});
return;
}
try{
downloadFile(file, request.session.gdrive_token.access_token, function (data) {
if(data){
cbk({success:true}, data, file.mimeType);
}
function listFiles (folder_id, request, response, next, cbk) {
oauth2Client.credentials = request.session.gdrive_token;
var search_params = {};
if (folder_id)
search_params.q = "'"+folder_id+"' in parents";
else
search_params.q = "'"+request.session.gdrive_account.rootFolderId+"' in parents";
googleapis
.discover('drive', 'v2')
.execute(function(err, client) {
if (err){
var errCode = null;
if (err.code){
errCode = err.code;
}
cbk ({success:false, code:errCode});
return;
}
client
.drive.files.list(search_params)
.withAuthClient(oauth2Client)
.execute(function (err, result, c) {