Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
info(req, function(err, info, new_client){
if (err) return next(err);
var old_client = new Dropbox.Client(config.dropbox);
old_client.setCredentials(req.session.old_credentials);
// Remove the old credentials
// This must happen before res.render
// or the session will not be saved...
req.session.old_credentials = null;
res.addLocals({dropbox_email: info.email});
res.title('Copy your files');
res.renderDashboard('folder/copy-files');
old_client.authenticate(function(err, old_client){
if (err) console.log(err);
var router = require('express').Router();
var request = require('request');
var parser = require('body-parser');
var bcrypt = require('bcrypt-nodejs');
var moment = require('moment');
var Dropbox = require('dropbox');
var Twitter = require('twitter');
// Dropbox Setup for server-based Authentication
var dropboxOptions = process.env.dropbox || require('./config.js').dropbox;
var client = new Dropbox.Client({ key: "yhintvoqspu0w44", secret: dropboxOptions });
// Twitter Setup
var twitterOptions;
if(process.env.dropbox === undefined){
twitterOptions = require('./config.js').twitter;
} else {
twitterOptions = {
consumer_key: process.env.twitter_consumer_key,
consumer_secret: process.env.twitter_consumer_secret,
access_token_key: process.env.twitter_access_token_key,
access_token_secret: process.env.twitter_access_token_secret
};
}
var twitterClient = new Twitter(twitterOptions);
// Database Requirements
function saveToDropBox (file, name, user) {
log('actually saving it now');
var client = new Dropbox.Client({
key: options.id,
secret: options.secret,
token: user.dropbox_token // jshint ignore:line
});
client.writeFile(name, file, function (err) {
if (err) {
process.send({
error: err,
user: user
});
}
log('saved!');
});
}
) {
return;
}
var token = /access_token=([^\&]*)/.exec(e.data)[1],
uid = /uid=([^\&]*)/.exec(e.data)[1],
state_r = /state=([^\&]*)/.exec(e.data)[1];
if (state !== state_r) {
return;
}
$.cookie('dbt', token);
$.cookie('dbu', uid);
client = new Dropbox.Client({
key: key,
sandbox: false,
token: token,
uid: uid
});
popup.close();
callback();
});
}
var DropboxClient = function DropboxClient(config) {
var client;
config = _.defaults(config, {
folder: ''
});
this._ensureValid(['token', 'folder'], config);
client = new Dropbox.Client({
token: config.token
});
DropboxClient.super_.call(this, config, client);
};
_getClient: function(complete, overrideAppKey) {
if (this._dropboxClient && this._dropboxClient.isAuthenticated()) {
complete(null, this._dropboxClient);
return;
}
if (!overrideAppKey && !this.isValidKey()) {
return complete(DropboxCustomErrors.BadKey);
}
const client = new Dropbox.Client({key: overrideAppKey || getKey()});
if (Launcher) {
client.authDriver(new Dropbox.AuthDriver.Electron({ receiverUrl: location.href }));
} else {
client.authDriver(new Dropbox.AuthDriver.Popup({ receiverUrl: location.href }));
}
client.authenticate((error, client) => {
if (!error) {
this._dropboxClient = client;
}
complete(error, client);
});
},
function _authorize(authStr) {
try {
auth = JSON.parse(authStr);
this.log("FsDropbox.authorize(): auth:" + util.inspect(auth));
} catch(e) {
return next(e);
}
req.dropbox = new dropbox.Client({
key: auth.appKey,
secret: auth.appSecret,
sandbox: true
});
req.dropbox.authDriver(new AuthDriver(auth));
req.dropbox.authenticate((function(err, client) {
if (err) {
return next(err);
}
this.log("dropbox:" + util.inspect(client));
next();
}).bind(this));
}
.then(function(text){
var client = new DropboxJS.Client({token: req.user.accessToken});
return self.writeFile_p(req.user.path, text,
req.body.revision, client)
.then(function(revs){
res.json(revs);
});
})
.fail(function(err){
function getClient() {
if (_dropboxClientPromise) return _dropboxClientPromise
var deferred = Q.defer();
var client = new Dropbox.Client({
key: provider_options.client_key,
secret: provider_options.client_secret,
token: _oauth_data.access_token
})
client.authenticate(function (err, client) {
if (err) return deferred.reject(err);
return deferred.resolve(client);
})
_dropboxClientPromise = deferred.promise
return _dropboxClientPromise;
}
DropboxDB.prototype.connect = function(options) {
this._client = new Dropbox.Client(options);
this._client.authDriver(new Dropbox.Drivers.NodeServer({port: 8192}));
};